I create a UIActionSheet
in the actionSheet: clickedButtonAtIndex delegate method.
- (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]; }
I am handling the click event of this UIActionSheet
in the same method as above.
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]; } }
The problem I am facing is that the UIActionSheet
takes too long to respond. When I click on the UIActionSheet
button, it is frozen for 2 or 3 seconds before myThirdView
loads. I cannot understand that the response delay in this case, as the first thing I do in the UIActionSheet
click event method, is to load myThirdView
. The rest of the code is only executed after the code to load myThirdView. But even the first line of code seems to be executed after a delay. Any suggestions?
source share