2017-06-02 423 views
0

我創建了三個場景,每個場景都有一個按鈕和一個標籤,如圖-1所示。 Scene1通過「Show Segue called scene1To2」鏈接到Scene2, ,Scene2通過「Show Segue called scene2To3」鏈接到scene3,最後Scene3通過「Show Segue called scene3To1」鏈接到scene1。prepareForSegue沒有被調用

我想叫「prepareForSegue」在SCENE1按鈕被點擊的時候,所以我寫了下面代碼1部分所示的代碼..

但是當我運行代碼的NSLog消息「的NSLog(@ 「從scene1到2過渡」);「不露面

請讓我知道爲什麼NSLog的消息不表明

代碼1

@interface ViewController() 

@end 

@implementation ViewController 

- (void)viewDidLoad { 
[super viewDidLoad]; 
// Do any additional setup after loading the view, typically from a 
//nib. 
} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
// Dispose of any resources that can be recreated. 
} 

- (IBAction)from1To2:(id)sender { 
    NSLog(@"Hi"); 

    [self performSegueWithIdentifier:@"scene1To2" sender:self]; 
} 

-(void)prepareForSegue:(UIStoryboardSegue *)segue 
{ 
    if ([segue.identifier isEqualToString:@"scene1To2"]) 
    { 
     NSLog(@"transiting from scene1To2"); 
    } 

    } 

    @end 

回答

1

你的方法簽名是錯誤的。看看這是否有訣竅:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
    if ([segue.identifier isEqualToString:@"scene1To2"]) 
    { 
     NSLog(@"transiting from scene1To2"); 
    } 
} 
-1

您可以使用類似這樣的東西,導入scene1To2控制器。

scene1To2 *view = [[UIStoryboard storyboardWithName:@"YOUR_STORYBOARD" bundle:nil] instantiateViewControllerWithIdentifier:@"scene1To2"]; 
[self presentViewController:view animated:YES completion:nil]; 

然後你去到其他視圖控制器

0

在對你添加的SEGUE名字到SEGUE標識故事板的Segue公司的聯繫?

相關問題