我需要将初始日期设置为"今天"之外的其他内容,以便用户进行选择.我发现如果用户没有做出选择,则日期/时间设置为"nil"; 我可以发送一个UIAlertView,但事实就是如此.
我看过SO和Google,但一无所获.我怎样才能做到这一点?
更新:实际上,我没有说明,但是没有显示年份,只有月份,日期和上午/下午.没有这一年,他们可能看不到未来的约会.Ť
我有一个iPhone应用程序,我目前正在使用Storyboard在XCode 4.3中构建.我有一个"根"视图控制器,两个(2)seques到包含UIWebView的视图控制器.我希望能够识别segue(已经为两个segue设置了唯一标识符),因此我可以根据在"根"视图控制器中激活了哪个segue,将正确的内容"推送"到UIWebView.
我想我必须使用"prepareForSegue"方法,但不知道它会去哪里.我在哪里可以找到如何处理两个segues到同一个视图控制器?(我已经谷歌了,发现没有什么适合我的情况).
这是我正在使用的代码:
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"helpSegue"]) {
NSLog(@"helpSegue");
}
else if ([segue.identifier isEqualToString:@"reportSegue"]) {
NSLog(@"reportSegue");
}
}
Run Code Online (Sandbox Code Playgroud) 我有这个代码,它应该将HTML文件附加到电子邮件中,并且还在电子邮件正文中显示HTML文件的内容.HTML文件中引用了一个图像(reading.png),每隔一行显示一次.但是,它不会显示在电子邮件正文中.我需要做些什么才能让它显示出来?
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self; // set delegate to notify us what's happen'in
[mailer setSubject:[NSString stringWithFormat: @"Site Readings for: %@", gSiteID.globalSiteID]];
// add the image for the HTML
UIImage *toolImage = [UIImage imageNamed:@"reading.png"];
NSData *imageData = UIImagePNGRepresentation(toolImage);
[mailer addAttachmentData:imageData mimeType:@"image/png" fileName:@"reading.png"];
// attach file
NSString *file = [[NSBundle mainBundle] pathForResource:@"Surveyor" ofType:@"txt"];
NSData *surveyorTxt= [NSData dataWithContentsOfFile: file];
[mailer addAttachmentData: surveyorTxt mimeType:@"text/html" fileName: @"Surveyor.txt"];
// display the file in the body of the …Run Code Online (Sandbox Code Playgroud) 我试图使用MagicalRecord设置Core Data的轻量级迁移.我使用Google和SO查看了有关此主题的所有帖子.我理解persistentStoreCoordinator如何工作以及我想要做的设置也是如此.
这是我的代码:
AppDeligate.h
NSPersistentStoreCoordinator *persistentStoreCoordinator;
Run Code Online (Sandbox Code Playgroud)
AppDelegate.m
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
if (persistentStoreCoordinator != nil) {
return persistentStoreCoordinator;
}
NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"saori.sqlite"]];
// handle db upgrade
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
NSError *error = nil;
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]];
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]) {
// Handle error
}
return persistentStoreCoordinator;
Run Code Online (Sandbox Code Playgroud)
}
我得到以下错误,我理解; 我不知道的是这些对象在哪里(我在我的应用程序中查找,并没有找到任何内容):
'AppDelegate'没有可见的@interface声明选择器'applicationDocumentsDirectory'和
'AppDelegate'没有可见的@interface声明选择器'managedObjectModel'
我已经创建了商店:

大多数,如果不是所有我看过的代码都是相似的; 我不知道MagicalRecord是否会为我处理这个问题,因为我找不到任何可以指示如何使用MR执行此操作的文档.我的问题是:我需要做些什么来完成这项工作?
我将此代码放在UIVIewController(XCode 6.1,iOS 8.1.1)中:
[UIAlertController showActionSheetInViewController:self
withTitle:@"Test Action Sheet"
message:NSLocalizedString(@"Are you sure you want to delete ALL appointments?",nil)
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Yes"
otherButtonTitles:@[@"No"] // same as Cancel
tapBlock:^(UIAlertController *controller, UIAlertAction *action, NSInteger buttonIndex){
if (buttonIndex == UIAlertControllerBlocksCancelButtonIndex) {
NSLog(@"Cancel Tapped");
} else if (buttonIndex == UIAlertControllerBlocksDestructiveButtonIndex) {
NSLog(@"Delete Tapped");
} else if (buttonIndex >= UIAlertControllerBlocksFirstOtherButtonIndex) {
NSLog(@"Other Action Index %ld", (long)buttonIndex - UIAlertControllerBlocksFirstOtherButtonIndex);
}
}];
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我得到这个运行时错误:
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIAlertController (<UIAlertController: 0x7fdfe3324f00>) …
这是我的代码:
NSPredicate *filter = [NSPredicate predicateWithFormat:@"aMostRecentFlag == 1"]; // find old records
NSFetchRequest *fetchRequest = [PreferenceData MR_requestAllWithPredicate: filter];
[fetchRequest setResultType: NSDictionaryResultType];
NSDictionary *preferenceData = [PreferenceData MR_executeFetchRequest:fetchRequest];
Run Code Online (Sandbox Code Playgroud)
我从构建中收到警告:
Incompatible pointer types initializing 'NSDictionary *' with an expression of type 'NSArray *'
Run Code Online (Sandbox Code Playgroud)
这表明MR没有按照文件记录返回NSDictionary; 我的代码有问题吗?顺便说一下,获取请求不会返回任何内容,尽管应该有一条记录.
我有一个现有的iPhone应用程序(iOS6,ARC,Storyboards,XCode5),我试图转换为通用.我做了一个复制和过渡到iPad,然后做了一个构建.这就是我得到的:
编译失败.无法写入路径:/ Users/sd/Documents/iPhone Apps/SurveyorLevelingI/DerivedData/SurveyorLevelingI/Build/Products/Debug-iphoneos/SurveyorLevelingI.app/en.lproj/MainStoryboard.storyboardc
我已将DerivedData文件夹移动到项目,清理项目,关闭XCode 5,检查DerivedData文件夹(它的777)的权限都无济于事.
接下来要检查什么的想法?
我有一个有多个版本的iPad应用程序; 我目前正在研究v2.1.1,我从远程存储库中检出了它.这是我点击源代码管理时看到的内容.这是什么意思,我该如何解决?

I have an app that has about 11 different Singleton instances used throughout the many app's methods and classes; it's getting out of hand, and I want to replace all of them with dependency injection, like Typhoon. However, I am unable to find any doc, sample or mention of how to replace the singletons with dependency injection, including Typhoon. For instance, do I use multiple instances of Typhoon, replacing each singleton with an instance of Typhoon?
我有一些代码正在处理我的某个应用程序; 所以我复制了代码,进行了必要的更改(即textField名称等),除非我将其移动到UIImageView,否则它会起作用; 没有出现.这是我的代码:
viewController.h(为简洁起见,仅显示相关部分)
#import "AppDelegate.h"
#import "Books.h"
#import <AVFoundation/AVFoundation.h>
#import "MBProgressHUD.h"
#import <MobileCoreServices/MobileCoreServices.h>
#import <UIKit/UIKit.h>
@class Books;
@interface DetailViewController : UIViewController <UITextFieldDelegate,
UIPopoverControllerDelegate,
UIPickerViewDataSource,
UIPickerViewDelegate,
UIActionSheetDelegate,
UIScrollViewDelegate,
UIImagePickerControllerDelegate,
AVCaptureMetadataOutputObjectsDelegate> {
}
// UIView
@property (strong, nonatomic) IBOutlet UIView *bookDetailView;
// camera stuff
@property (strong, nonatomic) IBOutlet UIImageView *oBookImage;
- (IBAction)bOpenCamera:(UIButton *)sender;
Run Code Online (Sandbox Code Playgroud)
这是相关的viewController.m代码:
#pragma mark - Camera stuff
- (IBAction)bOpenCamera:(UIButton *)sender {
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *imagePicker = [UIImagePickerController new];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects: (NSString …Run Code Online (Sandbox Code Playgroud) objective-c ×6
ios ×4
xcode5 ×2
core-data ×1
git ×1
ios6 ×1
ios8.1 ×1
segue ×1
storyboard ×1
typhoon ×1
uidatepicker ×1
xcode ×1
xcode7 ×1