iOS UIActionSheet的基本使用

NS_CLASS_DEPRECATED_IOS(2_0, 8_3, "UIActionSheet is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleActionSheet instead") __TVOS_PROHIBITED

創(chuàng)新互聯(lián)公司是專業(yè)的古城網(wǎng)站建設(shè)公司,古城接單;提供成都網(wǎng)站制作、成都做網(wǎng)站、外貿(mào)營(yíng)銷網(wǎng)站建設(shè),網(wǎng)頁設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行古城網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來合作!

在iOS8之后UIActionSheet (以及它們各自的 delegate protocols)已經(jīng)被棄用,用UIAlertController來代替,一下是iOS8之前和之后的2種做法:

double version = [[UIDevice currentDevice].systemVersion doubleValue];//判定系統(tǒng)版本。

 if(version>=8.0f){

    UIAlertController *alertController = [UIAlertControlleralertControllerWithTitle:@"提示"message:nilpreferredStyle:UIAlertControllerStyleActionSheet];

     [alertControlleraddAction:[UIAlertActionactionWithTitle:@"確定"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction * _Nonnull action) {

         NSLog(@"確定");

     }]];

     [alertControlleraddAction:[UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleDestructivehandler:^(UIAlertAction * _Nonnull action) {

         NSLog(@"取消");

     }]];

     [selfpresentViewController:alertControlleranimated:YEScompletion:nil];

 

 }else{

     #pragma clang diagnostic push

     #pragma clang diagnostic ignored "-Wdeprecated-declarations"

    UIActionSheet *sheetView = [[UIActionSheetalloc]initWithTitle:@"提示"delegate:selfcancelButtonTitle:nildestructiveButtonTitle:nilotherButtonTitles:@"確定",@"取消", nil];

     #pragma clang diagnostic pop

     sheetView.actionSheetStyle = UIActionSheetStyleDefault;

     [sheetView showInView:self.view];

     }

#pragma mark actionSheet_delegate 點(diǎn)擊事件

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex NS_DEPRECATED_IOS(2_0, 8_3) __TVOS_PROHIBITED{

    NSLog(@"%@",@(buttonIndex));

}

本文題目:iOS UIActionSheet的基本使用
網(wǎng)頁URL:http://www.muchs.cn/article28/ghgijp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗(yàn)、服務(wù)器托管、移動(dòng)網(wǎng)站建設(shè)、手機(jī)網(wǎng)站建設(shè)、做網(wǎng)站網(wǎng)站改版

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司