2012-01-15 8 views
0

iOS 5ストーリーボードに関する質問があります。最初のアプリ私はストーリーボードを使ってビルドしていますが、それらを使うのが好きですが、私の人生にとってUIActionSheetボタンからビューをロードする方法を理解できません。 UIActionSheetをうまく動かしてUIAddressBookピッカーを読み込みますが、新しいストーリーボードビューコントローラーに切り替える必要があります。iOS 5 UIActionSheetボタンからのビューの読み込み

アイデア?

ここでは、コードの一部です:

// Specify what to do when a user selects a button from the personSelectQuery 
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    if (buttonIndex == 0) { 
     [self showAddressPicker];//This works just fine to show the address book 

    } else if (buttonIndex == 1){ 
     [self showAddPersonView];//This is the custom storyboard view i want to load 
    } 
} 

答えて

3

[UIStoryboard instantiateViewControllerWithIdentifier:]方法を見てください。 IBの属性インスペクタで、特定のViewControllerの識別子を設定できます。この識別子をパラメータとして使用して上記のメソッドを呼び出すと、iOSはストーリーボードからViewControllerをインスタンス化します。残りはストーリーボードのない他のViewControllerと同じです。

+1

完璧に作業しました!このコードを使用します: 'AddPersonViewController * addPerson = [self.storyboard instantiateViewControllerWithIdentifier:@" AddPerson "]; [self.navigationController pushViewController:addPerson animated:YES]; ' – Brian