1
下一個按鈕不起作用。它會拋出一個錯誤Application tried to present modally an active controller
當我按next
按鈕時,我應該怎樣通過ViewControllers
數組來枚舉。我已經閱讀了許多有關同一問題的線索,但無法找出解決方案。提前致謝!枚舉位於堆棧中的ViewControllers
.h文件中
@property(nonatomic, strong) NSMutableArray *tab;
.m文件
- (IBAction)newTab:(id)sender {
UIStoryboard *st = [UIStoryboard storyboardWithName:[[NSBundle mainBundle].infoDictionary objectForKey:@"UIMainStoryboardFile"] bundle:[NSBundle mainBundle]];
myViewController *newTab = [st instantiateViewControllerWithIdentifier:@"myViewController"];
if (![newTab isBeingPresented]) {
[self presentViewController:newTab animated:YES completion:nil];
[tab addObject:newTab];
}
}
- (IBAction)next:(id)sender {
[tab enumerateObjectsUsingBlock:^(id object, NSUInteger idx, BOOL *stop) {
[self presentViewController:tab[idx] animated:YES completion:nil];
}]; }
- (IBAction)prev:(id)sender {
for (i=[tab count]; i>0; i--) {
if (![self isBeingDismissed]){
[tab[i-1] dismissViewControllerAnimated:YES completion:nil];
;
}}}
您不能再次展示相同的視圖控制器而不會解除它。將創建新實例成爲您的問題或那是什麼你不想要? –