2016-09-20 15 views
0

私はこの機能で自分自身を委任できない理由を知りたいと思います。UIlAertViewを自己委譲できません

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を追加しました。 私はあなたが私がこれから新しくなって以来、私を助けてくれることを願っています。 ありがとう!

+2

注:UIAlertViewは廃止され、間もなく削除されます。 UIAlertControllerを使用します。 –

+0

はUIAlertViewDelegateを自己拡張していますか?ああ、あなたのコードはARCでもなく、ios 5をサポートしていますか? :)そしてもしそうでなければ、iOS 8でUIAlertControllerを使うと、あなたのハンドラを特定のアクションに渡すことができます。 –

+0

ああ、あなたの関数foundJailbrokenDeviceがクラスコンテキストを持っていない可能性があります。典型的なクラスメソッドではありません。だからなぜあなたは使用しない - (void)foundJailbrokenDevice {}? –

答えて

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]; 
} 

そして[self foundJailbrokenDevice]foundJailbrokenDeviceの使用を交換してください。

関連する問題