我正在创建一个UIActionSheet
on actionSheet:clickedButtonAtIndex 委托方法。
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
if(buttonIndex == 1){
[self.myFirstView removeFromSuperview];
if (!self.mySecondView) {
[[NSBundle mainBundle] loadNibNamed:@"MySecondView" owner:self options:nil];
}
[self.mySecondView setFrame:CGRectMake(0, 0, 320, 480)];
[[UIApplication sharedApplication].keyWindow addSubview: self.mySecondView];
UIActionSheet * action = [[UIActionSheet alloc]initWithTitle:@""
delegate:self
cancelButtonTitle: nil
destructiveButtonTitle: deleteContacts
otherButtonTitles: cancel, nil];
action.tag = 102;
[action showInView:self.view];
[action release];
}
UIActionSheet
我以与上述完全相同的方法处理此点击事件。
if(actionSheet.tag == 102){
if(buttonIndex == 0){
if([[NSBundle mainBundle] loadNibNamed:@"MyThirdView" owner:self options:nil]) {
[self.myThirdView setFrame:CGRectMake(0, 0, 320, 480)];
[[UIApplication sharedApplication].keyWindow addSubview:self.myThirdView];
}
[self.mySecondView removeFromSuperview];
[self.doneButton.target performSelector:self.doneButton.action withObject:self.doneButton.target];
[self performSelector:@selector(RemoveView) withObject:self afterDelay:3.0];
}
}
我面临的问题是,UIActionSheet
需要太多时间来响应。当我点击UIActionSheet
按钮时,它在myThirdView
加载前处于冻结状态 2 或 3 秒。我无法理解,这种情况下的响应延迟是什么,因为我在UIActionSheet
按钮单击事件方法中做的第一件事就是加载myThirdView
。其余代码仅在加载 myThirdView 的代码之后执行。但即使是第一行代码似乎也会在延迟后执行。有什么建议么?