2016-08-04 19 views

答えて

1

Storybboard.SecondViewControllerの3つのcontrollers.ViewControllerとThirdViewControllerはXIBの部分です。

まず私はあなたがこれをacheiveする場合

#import "ViewController.h" 
#import "SecondViewController.h" 
@interface ViewController() 

@end 

@implementation ViewController 


- (IBAction)actionGoXIB:(id)sender 
{ 
    SecondViewController *secondVC = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil]; 
    [self.navigationController pushViewController:secondVC animated:YES]; 
} 

は今、私は最初のストーリーボードをクリックしに行く、XIB

からStoyboardを呼ぶストーリーボード

ViewController.mからXIBを呼び出しますThirdViewController

クリック - >アイデンティティインスペクタ

、[OK]をクリックします - >アイデンティティ

今すぐ

enter image description here enter image description here

下のスクリーンショットを参照してください

アイデンティティ セクションでThirdViewControllerにストーリーボードIDを設定します。

SeconViewController。 m

#import "SecondViewController.h" 
#import "ThirdViewController.h" 

@interface SecondViewController() 

@end 

@implementation SecondViewController 

- (IBAction)actionGoStoryboard:(id)sender 
{ 
    UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
    ThirdViewController *thirdVC = [mainStoryBoard instantiateViewControllerWithIdentifier:@"ThirdViewController"]; 
    [self.navigationController pushViewController:thirdVC animated:YES]; 
    // [self presentViewController:thirdVC animated:YES completion:nil]; 
} 
+0

presentViewControllerを使用する必要がある場合はどうすればよいですか? navigationControllerではありませんか? – iphonemaclover

+0

あなたは現在のビューコントローラを使用することはできますが、プッシュと混同してコントローラを表示することはできません。両方を使用する場合は、別々のビューコントローラの設定をしてください。プッシュを使用してナビゲートする場合は1つのビューコントローラ、また、ビューコントローラを表示する場合は、同じビューコントローラから別のビューコントローラを使用します。 – user3182143

関連する問題