【问题标题】:UIAction Sheet not working on iPad but working in SimulatorUIAction Sheet 不能在 iPad 上工作,但在模拟器中工作
【发布时间】:2012-11-27 14:01:05
【问题描述】:

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

【问题讨论】:

  • 首先尝试从 iPad 上删除应用程序,然后使用 Xcode 重新安装..

标签: xcode ipad ios-simulator uiactionsheet


【解决方案1】:

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

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

    }
}

【讨论】:

  • actionSheet 正在显示,但与其关联的委托没有响应。
  • 试试这个 if ([[actionSheet buttonTitleAtIndex:buttonIndex] isEqual:@"A"]) { }
  • 所有操作表都有同样的问题.. 一个不工作.. 模拟器上的一切似乎都很好..!! :-(
  • 在delegate方法中打印NSlog就可以了,这样就知道是不是调用了
【解决方案2】:

问题解决了。

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

这对我有用。

【讨论】:

    猜你喜欢
    • 2011-05-29
    • 2016-10-17
    • 1970-01-01
    • 2013-05-05
    • 2012-08-19
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    • 2016-05-09
    相关资源
    最近更新 更多