ios - Action Sheet 在 iphone 中有效,但在 ipad 中无效

标签 ios objective-c ipad uiactionsheet

操作表在 iPhone 上运行良好,但当我在 iPad 上尝试时,它不起作用。有什么解决办法吗?

我的代码如下:

-(void)setUpAlertCtrl{
    self.alertCtrl=[UIAlertController alertControllerWithTitle:@"Select Image"
                                                       message:nil
                                                preferredStyle:UIAlertControllerStyleActionSheet];
}

最佳答案

试试这个

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

{

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:@"Your message" preferredStyle:UIAlertControllerStyleActionSheet];

// Remove arrow from action sheet.
[alertController.popoverPresentationController setPermittedArrowDirections:0];
//For set action sheet to middle of view.
CGRect rect = self.view.frame;
rect.origin.x = self.view.frame.size.width / 20;
rect.origin.y = self.view.frame.size.height / 20;
alertController.popoverPresentationController.sourceView = self.view;
alertController.popoverPresentationController.sourceRect = rect;

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

关于ios - Action Sheet 在 iphone 中有效,但在 ipad 中无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37894600/

相关文章:

iphone - 添加到 View 后删除 UIPanGestureRecognizer

ios - 解析 : JSON text did not start with array or object and option to allow fragments not set

objective-c - 我无法获取使用 XCode 5 的 Collection View 编程主题教程

ios - 使用 Swift 检查互联网连接

ios - 如何检查 Parse key 是否为空?如果是这样,那么将其更改为 0,而不是什么都没有

objective-c - 如何更改在 NSKeyedArchiver 中编码的对象的层次结构?

ios - Ipad 信用卡读卡器 : Getting the card data from the native app into a webview to send via standard http post

ipad - iPad 上的 OCamlexample 应用程序是否可用?

ios - 使用自定义单元格在 UITableView 上进行多点触控

ios - UIImage 显示一个空方 block 而不是图像