2012-08-12 37 views
0

爲什麼當另一個segue結束時不能調用segue?我猜一定是我的代碼錯了或者不可能打電話?當另一個segue結束時調用segue

- (IBAction)optionTapped 
{ 
    if (greeting) 
     { 
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alerta!" message:@"something.." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; 
      [alert show]; 
      [self performSegueWithIdentifier:@"firstSegue" sender:itemToSent]; 
      greeting = NO; 
     } 
    else 
     { 
      [self performSegueWithIdentifier:@"anotherSegue" sender:nil]; 
     } 
} 

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    if ([segue.identifier isEqualToString:@"anotherSegue"]) { 
     UIViewController *viewController = segue.destinationViewController; 
     OptionsViewController *controller = (OptionsViewController *)viewController; 
     controller.delegate = self; 
    } else if ([segue.identifier isEqualToString:@"firstSegue"]) { 
     UINavigationController *navigationController = segue.destinationViewController; 
     CCGetViewController *controller = (CCGetViewController *)navigationController.topViewController; 
     controller.delegate = self; 
     controller.itemToSent = sender; 
    } 

- (void)firstSegueViewController:(CCGetViewController *)controller didFinishAddItem:(InfoListItems *)item 
{ 
    itemToSent = item; 
    [self dismissViewControllerAnimated:YES completion:nil]; 
    if (scanTap) { 
     [self scanTapped]; 
    } else if(infoTap){ 
     [self optionTapped]; 
    } 
} 

還有一件事:「firstSegue」嵌入在NavigationController中,「anotherSegue」只是一個視圖控制器。

回答

1

我試圖不斷移動segue,但我也失敗了。

所以我試圖設置第一個賽格和第二個賽格之間的間隔一秒鐘。

ss

這個效果很好!當您按下紅色窗口中的按鈕時,會出現綠色窗口,之後會自動出現藍色窗口。

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
    [self performSelector:@selector(segue) withObject:nil afterDelay:1.0]; 
} 

- (void)segue 
{ 
    [self performSegueWithIdentifier:@"toBlue" sender:self]; 
} 

您可以下載示例項目和公正的運行它:

https://github.com/weed/p120812_DoubleSegue