2012-10-07 32 views
1

我想爲我的應用創建一個用戶指南,只顯示一次。我如何創建一個簡單的UIModalPresentationFormSheet,其中包含一些文本?創建一個UIModalPresentationFormSheet

編輯:

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

回答

0

你可以在NSUserDeafualts存儲價值。所以在你的主UIViewController viewDidAppear:

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

希望這有助於。

+0

但我怎麼能實際加載它(請參閱編輯,我試過代碼) – Alessandro

+0

iOS的目標是? – stringCode

+0

5.1至6.0。我使用故事板 – Alessandro