我有一个基于“基于窗口的应用程序”模板的 iPhone 应用程序,它使用带有一些嵌入式子视图的主视图。
对于某些操作,我需要用户确认。因此,我创建了一个 UIActionSheet 并要求用户提供反馈。
问题是,操作表根本没有显示。相反,屏幕变暗。工作表和请求的按钮不显示。之后,应用程序挂起。屏幕变暗是作为动画的一部分的正常行为,通常显示动作表。
奇怪的是,如果在 viewDidLoad 方法中调用相同的代码,也可以正常工作。如果在启动需要确认的操作的 buttonPressed 方法中调用,它不起作用。
- (void) trashButtonPressed {
// This method is called in the button handler and (for testing
// purposes) in the viewDidLoad method.
NSLog( @"trashButtonPressed" );
UIActionSheet* actionSheet =
[[UIActionSheet alloc] initWithTitle: @"Test"
delegate: self
cancelButtonTitle: @"Cancel"
destructiveButtonTitle: @"Delete Sheet"
otherButtonTitles: nil];
[actionSheet showInView: self.view];
[actionSheet release];
}
- (void) willPresentActionSheet:(UIActionSheet *) actionSheet {
NSLog( @"willPresentActionSheet" );
}
- (void) didPresentActionSheet:(UIActionSheet *) actionSheet {
NSLog( @"didPresentActionSheet" );
}
- (void) actionSheet:(UIActionSheet *)actionSheet
didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSLog( @"actionSheet:didDismissWithButtonIndex" );
}
如您所见,我已将一些日志消息添加到 UIActionSheetDelegateProtocol 的协议处理程序中。“将呈现”和“确实呈现”方法按预期调用,但工作表未显示。
有谁知道,这里有什么问题?