是的,我已经用Google搜索了这个问题并且我已经使用了确切的代码,但这仍然没有用。
这是我目前的Objective-C代码:
- (IBAction)btnTemp:(id)sender
{
if (_deepSwitch.on == TRUE)
{
[self TempCleaner];
_progress.progress += 1;
}
UIAlertView *cleaned = [[UIAlertView alloc] initWithTitle:@"Done!" message:@"Your device is now clean. Restarting SpringBoard." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[cleaned show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == [alertView cancelButtonIndex]) {
NSLog(@"clicked");
}
}
为什么这不起作用?我已尝试过buttonIndex 0,并取消按钮!
答案 0 :(得分:1)
将提醒视图的委托设置为self
UIAlertView *cleaned = [[UIAlertView alloc] initWithTitle:@"Done!" message:@"Your device is now clean. Restarting SpringBoard." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
此外,请确保您提供警报视图的类声明UIAlertViewDelegate
协议
//YourClass.h
@interface YourClass : SuperClass <UIAlertViewDelegate>