我有一个奇怪的问题。当我在模拟器上运行我的应用程序时,一切正常,但在设备上,某些代码仍然无法响应!我有一个UIActionSheet,在Simulator上看起来还不错,但是在设备上根本无法正常工作。它甚至可以在iPod上运行:
这是显示操作表的代码:
UIActionSheet *DeleteAction = [[UIActionSheet alloc] initWithTitle:@"Select Delete Option" delegate:self cancelButtonTitle:Nil destructiveButtonTitle:nil otherButtonTitles:nil, nil];
[DeleteAction addButtonWithTitle:@"A"];
[DeleteAction addButtonWithTitle:@"B"];
[DeleteAction showInView:self.view];
并且我正在使用该委托作为操作表
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if ([actionSheet buttonTitleAtIndex:buttonIndex] == @"A") {....}
if ([actionSheet buttonTitleAtIndex:buttonIndex] == @"B") {....}
}
我已经使用了此代码,并且工作正常。让我知道它是否显示操作表]
-(void)share {
UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:@"cancel" destructiveButtonTitle:nil otherButtonTitles:@"Email this Info",@"Tweet this Info",@"Share On Facebook", nil];
popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[popupQuery showInView:self.view];
[popupQuery release];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
[self emailinfo];
}
if (buttonIndex == 1) {
[self tweetinfo];
}
if (buttonIndex == 2) {
[self shareonfacebook];
}
if (buttonIndex == 3) {
}
}
问题已解决。
if ([[actionSheet buttonTitleAtIndex:buttonIndex]isEqualToString: @"A"]) {....}
这对我有用。