0

我一直在尝试在我的应用程序中使用 UIActionSheet。这个想法是,如果您以某种状态退出应用程序,它会在启动时弹出并询问您是否要继续或重置。这是代码:

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];
}

这是在 viewDidLoad 中。实际的代码操作是:

- (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];  
 }
}

这一切看起来都很简单,但由于某种原因,它在 iPhone 上运行没有问题,但在 iPad 上,程序此时崩溃。

4

1 回答 1

0

好吧,这个得到了一个大胖 DOH!在重新开发它们后,我错误地实现了 iPad XIB,这按设计工作。

于 2010-11-06T17:24:26.643 回答