在我的应用程序中,当用户单击按钮时,它会调用 prepareForSegue。应用程序需要检查状态,然后提示用户是否要覆盖或删除。问题是它在显示 UIActionSheet 之前加载了下一个视图控制器。如何在调用 prepareForSegue 之前强制 UIActionSheet 出现?这是我对 prepareForSegue 的逻辑;
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([[segue identifier] isEqualToString:@"mySegue"]) {
//Check Logic removed for simplicity
if ([myCheck count] > 0){
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@"Save?"
delegate:self
cancelButtonTitle:@"Delete"
destructiveButtonTitle:@"Save"
otherButtonTitles:nil];
[actionSheet showFromToolbar:self.navigationController.toolbar];
}
}
}
这是行动表;
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex == [actionSheet cancelButtonIndex])
{
//Delete logic removed
}else {
//Save logic removed
}
}