【发布时间】:2010-08-01 00:24:09
【问题描述】:
我有一个基于“基于窗口的应用程序”模板的 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 的协议处理程序中。 "will present" 和"did present" 方法按预期调用,但工作表没有显示。
有谁知道,这里出了什么问题?
【问题讨论】:
-
iphone-sdk-3 标签?您实际上仍在使用 3.x SDK?
标签: iphone uiactionsheet iphone-sdk-3.0