2016-09-13 9 views
0

は表示されません。 is null:UIAlertViewとUIAlertControllerタイトルは次のように私は、アラートを作成している

これを修正するにはどうすればよいですか?

+0

:それを使用しないでください

は、このコードを使用してみてください。 iOS 8では廃止予定です。 – FelixSFD

+0

コードのどこかにsetTitleを使用していますか? – vishnuvarthan

+1

goto製品 - >クリーンしてもう一度やり直してください – KSR

答えて

0

どちらも私の側で働いています。あなたはUIAlertView` `のためならば修正しようとする前に

#import "ViewController.h" 

@interface ViewController() 

@end 

@implementation ViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"WARNING" message:@"Are you sure you want to quit ?" delegate:nil cancelButtonTitle:@"Confirm" otherButtonTitles:@"Cancel", nil]; 
    [alertView show]; 

    [self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(grHandler)]]; 
} 

-(void)grHandler{ 
    // UIAlertController 
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"WARNING" message:@"Are you sure you want to quit ?" preferredStyle:UIAlertControllerStyleAlert]; 
    [alertController addAction:[UIAlertAction actionWithTitle:@"Confirm" style:UIAlertActionStyleDefault handler:NULL]]; 
    [alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:NULL]]; 
    [self presentViewController:alertController animated:YES completion:NULL]; 
} 

@end 
+0

私は新しいプロジェクトを作成します(iOS7以降用)、コードは機能しますが、会社のプロジェクト –

関連する問題