2014-09-20 55 views

回答

5

您是否在應用程序中爲ViewController添加了任何類別。如下圖所示

@implementation UIViewController (CustomeAction) 
- (void)setTitle:(NSString *)title{ 
// YOU CODE/// 
} 
@end 

這可能是問題所在。我已通過刪除此類別來解決- (void)setTitle:(NSString *)title.

注意:從iOS 8開始,UIAlertViewController從UIViewController繼承。如果您使用分類方法,則會對UIAlertView標題產生影響。

您可以在UIAlertController Class Reference

+0

偉大的...它的做工精細碼...感謝 – Surfer 2014-09-23 11:45:11

+0

的歡迎,如果你需要設置標題,那麼你可以編寫UINavigationItem的類別。 – Nookaraju 2014-09-23 12:05:23

+0

好的。非常感謝你.. – Surfer 2014-09-23 12:09:45

0

應當注意的是,UIAlertView中和UIActionSheet被棄用的iOS 8.您可以檢查出this questionapple link。可能會幫助你。

0

參考蘋果的文檔您可以使用下面使用UIAlerController爲6的XCode和IOS 8

UIAlertController * alert= [UIAlertController 
           alertControllerWithTitle:@"Title" 
           message:@"Your Message" 
           preferredStyle:UIAlertControllerStyleAlert]; 

    UIAlertAction* ok = [UIAlertAction 
         actionWithTitle:@"OK" 
         style:UIAlertActionStyleDefault 
         handler:^(UIAlertAction * action) 
         { 
          [alert dismissViewControllerAnimated:YES completion:nil]; 

         }]; 
    UIAlertAction* cancel = [UIAlertAction 
          actionWithTitle:@"Cancel" 
          style:UIAlertActionStyleDefault 
          handler:^(UIAlertAction * action) 
          { 
           [alert dismissViewControllerAnimated:YES completion:nil]; 

          }]; 

    [alert addAction:ok]; 
    [alert addAction:cancel]; 

    [self presentViewController:alert animated:YES completion:nil]; 

對於ActionSheet

UIAlertController * alert= [UIAlertController 
            alertControllerWithTitle:@"Title" 
            message:@"Your Message" 
            preferredStyle:UIAlertControllerStyleActionSheet];