操作表在 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/