UIActionSheet Controller crashed on iPad and Works Fine on iPhone
I've been trying to work a UIActionSheet into my App. The idea is, if you exited the app in a certain state, it would popup on launch and ask you if you'd like to continue or reset. Here's the code:
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
continueYesNo = [prefs bool开发者_JAVA百科ForKey:@"keyContinueMeeting"];
if (continueYesNo) {
NSString *message_continue = [[NSString alloc] initWithFormat:@"Do you want to Continue the Prior Meeting"];
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:message_continue
delegate:self
cancelButtonTitle:@"Reset"
destructiveButtonTitle:@"Continue"
otherButtonTitles:nil];
[actionSheet showInView:self.view];
[actionSheet release];
[message_continue release];
}
This is in viewDidLoad. And the actual Code action is:
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
Wasted_TimeAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
if (buttonIndex != [actionSheet cancelButtonIndex]) {
delegate.continueMeeting = YES;
[prefs setBool:YES forKey:@"keyContinueMeeting"];
[ [NSUserDefaults standardUserDefaults] synchronize];
} else {
delegate.continueMeeting = NO;
[prefs setBool:NO forKey:@"keyContinueMeeting"];
[ [NSUserDefaults standardUserDefaults] synchronize];
}
}
It all seems pretty straight forward, but for some reason it runs on the iPhone with no problem but on the iPad the program crashes at this point.
Ok this one get's a big fat DOH! I had incorrectly implemented the iPad XIB, after redeveloping them this works as designed.
精彩评论