创建一个UIModalPresentationFormSheet

时间:2012-10-07 11:06:20

标签: ios xcode

我想为我的应用创建一个用户指南,只显示一次。如何创建一个包含一些文本的简单UIModalPresentationFormSheet?

编辑:

UIViewController *newItemViewController = [[UIViewController alloc] initWithNibName:@"View.xib" bundle:nil];
newItemViewController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:newItemViewController animated:YES];

1 个答案:

答案 0 :(得分:0)

您可以在NSUserDeafualts中存储值。所以在viewDidAppear的主要UIViewController中:

 #define SHOULD_SHOW_KEY @"shouldShowKey"
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
//Get user defaults
NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
//if there is no object for SHOULD_SHOW_KEY present modal contoroler
if (![defaults objectForKey:SHOULD_SHOW_KEY]) {
    //Set object for key and synchronize defaults
    [defaults setObject:SHOULD_SHOW_KEY forKey:SHOULD_SHOW_KEY];
    [defaults synchronize];
    //Present any custom modal controller
    UIViewController *yourModalVC=[self.storyboard instantiateViewControllerWithIdentifier:@"myModalVC"];
    [self presentModalViewController:yourModalVC animated:YES];
}
}

希望这会有所帮助。