'UIAlertController'에 해당되는 글 1건

  1. 2018.04.26 [Objective-C] UIAlertController 사용시 패드에서 종료되는 문제
Dev/Objective-C2018. 4. 26. 11:45
#define IS_IPAD [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad
- (IBAction)showAlert:(UIButton *)btn
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[alert addAction:[UIAlertAction actionWithTitle:@"확인" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action){
// 확인
}]];
[alert addAction:[UIAlertAction actionWithTitle:@"취소" style:UIAlertActionStyleCancel handler:NULL]];
if (IS_IPAD){
UIPopoverPresentationController *popPresenter = [alert popoverPresentationController];
popPresenter.sourceView = sender;
popPresenter.sourceRect = sender.bounds;
}
[self presentViewController:alert animated:YES completion:NULL];
}
view raw ViewContoller.m hosted with ❤ by GitHub
Posted by iDeveloper