操作表不能在iPad上工作但在Simulator中工作

时间:2012-12-10 06:41:13

标签: xcode ipad ios-simulator uiactionsheet

我遇到了一个奇怪的问题。当我在模拟器上运行我的应用程序一切正常但在设备上一些代码无论如何都没有响应.. !!我有一个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") {....}
}

朋友们,我正在寻找你的帮助......  提前致谢  阿弥陀佛

2 个答案:

答案 0 :(得分: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) {

    }
}

答案 1 :(得分:2)

问题解决了。

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

这对我有用。