NS_CLASS_DEPRECATED_IOS(2_0, 8_3, "UIActionSheet is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleActionSheet instead") __TVOS_PROHIBITED
在iOS8之后UIActionSheet (以及它們各自的 delegate protocols)已經被棄用,用UIAlertController來代替,一下是iOS8之前和之后的2種做法:
double version = [[UIDevice currentDevice].systemVersion doubleValue];//判定系統版本。
if(version>=8.0f){
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[alertController addAction:[UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"確定");
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"取消");
}]];
[self presentViewController:alertController animated:YES completion:nil];
}else{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
UIActionSheet *sheetView = [[UIActionSheet alloc] initWithTitle:@"提示" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"確定",@"取消", nil];
#pragma clang diagnostic pop
sheetView.actionSheetStyle = UIActionSheetStyleDefault;
[sheetView showInView:self.view];
}
#pragma mark actionSheet_delegate 點擊事件
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex NS_DEPRECATED_IOS(2_0, 8_3) __TVOS_PROHIBITED{
NSLog(@"%@",@(buttonIndex));
}
另外有需要云服務器可以了解下創新互聯scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業上云的綜合解決方案,具有“安全穩定、簡單易用、服務可用性高、性價比高”等特點與優勢,專為企業上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
當前標題:iOS UIActionSheet的基本使用-創新互聯
URL地址:http://vcdvsql.cn/article20/cedeco.html
成都網站建設公司_創新互聯,為您提供網站導航、定制網站、網站制作、企業網站制作、營銷型網站建設、App開發
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯