3

我有一个奇怪的问题。当我在模拟器上运行我的应用程序时,一切正常,但在设备上,一些代码无论如何都没有响应!我有一个 UIActionSheet 在模拟器上看起来不错,但在设备上它根本不起作用。它甚至可以在 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") {....}
}
4

2 回答 2

2

我已经使用了这段代码并且工作正常。让我知道它是否显示操作表

-(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) {

    }
}
于 2012-12-10T06:54:01.057 回答
2

问题解决了 。

 if ([[actionSheet buttonTitleAtIndex:buttonIndex]isEqualToString: @"A"]) {....}

这对我有用。

于 2013-02-05T09:21:35.337 回答