我有一個表格視圖,其中有不同類型的表格視圖單元格。在其中一個單元中,有兩個按鈕,它們在按下時加載視圖控制器。我正在使用以下功能來處理按鈕按下:iOS segue執行兩次
- (IBAction)leftButtonPressed:(id)sender
{
// Getting the pressed button
UIButton *button = (UIButton*)sender;
// Getting the indexpath
NSIndexPath *indPath = [NSIndexPath indexPathForRow:button.tag inSection:0];
// Loading the proper data from my datasource
NSArray *clickedEvent = [[[SOEventManager sharedEventManager] eventsArray] objectAtIndex:indPath.row];
[[SOEventManager sharedEventManager] setSelectedEvent:clickedEvent[0]];
// Everything working as it should up to this point
// Performing seque...
[self performSegueWithIdentifier:@"buttonSegue" sender:self];
}
我buttonSegue應該推新視圖控制器。不知怎的,而不是推一次,這似乎是推兩次,所以我得到以下警告:
2013-11-27 01:48:30.894 Self-Ordering App[2081:70b] nested push animation can result in corrupted navigation bar
2013-11-27 01:48:31.570 Self-Ordering App[2081:70b] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
在我的情況下,它會導致崩潰,因爲在我希望應用程序立即彈出一個事件視圖控制器,所以它回到我的表視圖。我使用alertview對於這一點,並具有以下處理事件:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *buttonTitle = [alertView buttonTitleAtIndex:buttonIndex];
// ...
// Additional checking of button titles....
else if ([buttonTitle isEqualToString:NSLocalizedString(@"Vissza", nil)])
{
[self.navigationController popViewControllerAnimated:YES];
}
}
也許我感興趣的是,我有我的「正規」表視圖細胞的其他SEGUE,在這種情況下,我使用prepareForSegue :方法
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"detailSegue"])
{
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
SOEvent *selectedEvent = [[[SOEventManager sharedEventManager] eventsArray] objectAtIndex:indexPath.row];
[[SOEventManager sharedEventManager] setSelectedEvent:selectedEvent];
}
}
在這種情況下,視圖控制器被完全推入,甚至在需要時立即彈出。我在iOS7和Xcode 5上測試這個。我以前沒有遇到過這樣的問題,任何幫助將不勝感激。
你確定你已經在界面構建器中正確地連接了這些動作嗎?也許你已經爲事件提供了線索,比如觸摸內部並觸及內部,而不是觸及內部。或者您也可以從代碼中再次分配segue,並在界面構建器中再次分配segue。你有檢查他們嗎?這是一個常見的錯誤。 –
哦該死..你其實是對的,我也指定我的按鈕也在表視圖數據源方法..謝謝你的答案! –