我有这个警告 View (免责声明),它会在应用程序完成启动时弹出。它可以工作(我的应用程序现在慢得多),但如果用户按 no,thanks
,我也想退出应用程序。我想我应该使用 clickedButtonAtIndex:.
1. 有人可以帮我解决这个问题吗?
2. viewDidLoad 是应用程序启动时触发 alertView 的最佳方法吗?
3. 有什么原因导致我的应用程序在构建和运行时需要更多时间才能启动?
-(void)viewDidLoad {
UIAlertView *disclaimer = [[UIAlertView alloc] initWithTitle: @"DISCLAIMER" message:@"This Application is provided without any express or implied warranty. Errors or omissions in either the software or the data are not guaranteed against. The application is not intented to replace official documentation or operational procedure. In no event shal the developer be held liable for any direct or indirect damages arising from the use of this application" delegate:self cancelButtonTitle:@"No, thanks" otherButtonTitles:@"Accept", nil];
[disclaimer show];
[disclaimer release];
[super viewDidLoad];
}
最佳答案
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0)
// Do something
else
// Some code
}
或
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0)
// Do something
else
// Some code
}
确保您的类符合 UIAlertViewDelegate
协议(protocol)。
而且我认为退出应用程序不是一个好方法。您应该只让用户通过按主页按钮关闭应用程序。这违背了用户期望每个应用程序都遵循的默认行为。
关于iphone - 警报 View - 如何使用 clickedButtonAtIndex :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6199342/