在iOS8以前,我們都習慣性用UIAlertView去做提示框,iOS8以后,蘋果提倡使用UIAlertController取代UIAlertView。
#define SYSTEM_VERSION [[UIDevice currentDevice].systemVersion floatValue]
if (SYSTEM_VERSION >= 8.0) { UIAlertController *alertCtrl = [UIAlertController alertControllerWithTitle:@"贖回成功" message:nil preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [self.navigationController popViewControllerAnimated:YES]; }]; [alertCtrl addAction:okAction]; [self presentViewController:alertCtrl animated:YES completion:nil]; }else{ //這個else一定要寫,否則會導致在ios8一下的真機crash UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"贖回成功" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:@"確定", nil]; alert.tag = 998; [alert show]; }
#pragma mark-UIAlertViewDelegate -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (alertView.tag == 998) { [self.navigationController popViewControllerAnimated:YES]; } }
另外有需要云服務器可以了解下創新互聯scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業上云的綜合解決方案,具有“安全穩定、簡單易用、服務可用性高、性價比高”等特點與優勢,專為企業上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
本文名稱:IOS8以上的UIAlertView-創新互聯
標題網址:http://vcdvsql.cn/article42/cdedec.html
成都網站建設公司_創新互聯,為您提供App開發、云服務器、電子商務、定制網站、做網站、Google
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯