简体   繁体   English

UIActionSheet Controller在iPad上崩溃,在iPhone上运行正常

[英]UIActionSheet Controller crashed on iPad and Works Fine on iPhone

I've been trying to work a UIActionSheet into my App. 我一直在尝试在我的应用程序中使用UIActionSheet。 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 boolForKey:@"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. 这是在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. 一切看起来似乎很简单,但是由于某种原因,它可以在iPhone上正常运行,但是在iPad上,程序此时崩溃了。

Ok this one get's a big fat DOH! 好的,这是个很大的DOH! I had incorrectly implemented the iPad XIB, after redeveloping them this works as designed. 在重新开发iPad XIB之后,我错误地实现了iPad XIB,使其按设计工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM