我想知道为什么我不能在这个功能上委托自己。
void foundJailbrokenDevice()
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Jailbrokeb=n Device Detected" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
- (void)alertView:(UIAlertView *) alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
UIApplication *app = [UIApplication sharedApplication];
[app performSelector:@selector(suspend)];
[NSThread sleepForTimeInterval:2.0];
exit(0);
}
}
消息显示使用未声明的标识符“self”。我已经在我的.h文件中添加了UIAlertViewDelegate 我希望你们能帮助我,因为我是新手。 谢谢!
答案 0 :(得分:0)
我认为您应该将函数foundJailbrokenDevice
替换为以下类方法:
-(void) foundJailbrokenDevice
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Jailbrokeb=n Device Detected" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
并将foundJailbrokenDevice
的使用情况替换为[self foundJailbrokenDevice]
。