1

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

编辑:

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

1 回答 1

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];
}
}

希望这有帮助。

于 2012-10-07T11:37:06.987 回答