2014-10-08 36 views

回答

14

是的,我確實得到了這個問題。我在iOS7中開發了我的代碼,但也必須兼容iOS 8。所以我碰到了This link。我得到我的解決方案如下:

當你使用iOS7 UIAlertView工作正常,但如果你使用iOS8你必須使用UIAlertController。使用這種代碼:

if(SYSTEM_VERSION_LESS_THAN(@"8.0")) 
{ 
    alert = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"Invalid Coupon." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
     [alert show]; 
} 
     else 
     { 
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Warning" message:@"Invalid Coupon." preferredStyle:UIAlertControllerStyleAlert]; 


     UIAlertAction *okAction = [UIAlertAction 
            actionWithTitle:NSLocalizedString(@"OK", @"OK action") 
            style:UIAlertActionStyleDefault 
            handler:^(UIAlertAction *action) 
            { 

            }]; 

     [alertController addAction:okAction]; 

     [self presentViewController:alertController animated:YES completion:nil]; 
    } 

希望這會幫助你。

+0

謝謝@iAnurag:D – Salmo 2014-10-08 17:37:11

+0

歡迎。樂意效勞 – iAnurag 2014-10-09 06:51:41

相關問題