我真的工作的一个项目,其中的警报应来自控制器返回一个空值之后弹出。它弹出在模拟器,但在iPhone上从控制器返回时,应用程序冻结并退出。有任何想法吗?

下面是我的代码:

  - (void)manualBarcodeViewControllerDidFinish:(ManualBarcodeViewController *)controller
    {

        ......
        ......

        else if([barcode isEqualToString:@""])
        {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"error" message:@"message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"otherbutton"];
            [alert show];
        [alert release];
         }
     }
有帮助吗?

解决方案

otherButtonTitles参数需要是零终止的。

在一般情况下,采用可变数目的参数的方法,需要在端部具有零。例如:

[NSArray arrayWithObjects:objA, objB, nil];

和你的情况:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"error" message:@"message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"otherbutton", nil];

其他提示

你应该看看这个问题,也许这将有助于:

UIAlertView中导致释放模式碰撞

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top