2011-11-01 20 views
0

我在xCode 4.2中的故事板有問題。檢查是否有可能,如果布爾值爲true以加載下一個視圖,或者如果爲false,則不加載新視圖留在實際視圖中。if語句在prepareForeSegue中的iOS 5

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    if ([[segue identifier] isEqualToString:@"toCategory"] && ([[codeField text] isEqualToString:@"1234"])) 
     {     
       QuestInfoController *qicontroller = [segue destinationViewController]; 
     } 
    else 
     { 
     [super prepareForSegue:segue sender:self]; 
     return; 

     } 
} 

回答

1

是的,但你不這樣做很像這樣。您可以使用自定義方法或檢查布爾值 - 然後使用performSegueWithIdentifier:根據結果強制進行轉換。

I wrote another post about it here.它演示瞭如何連接頁面上的幾個按鈕以推送下一個視圖。請注意,在buttonPressed:方法中,您將執行檢查。