在ipad上的动作表 [英] Actionsheet on ipad

查看:184
本文介绍了在ipad上的动作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码在iPhone上运行正常,但在iPad上,操作表显示在屏幕中间。不在触发按钮所在的角落。此外,没有取消按钮显示。

This code works fine on iPhone, but on iPad the actionsheet is showing up in the middle of screen. not in the corner where the trigger button is. Also there is no cancel buttons showing up.

此外,该应用程序仅处于横向模式。相机触发按钮位于屏幕的右上角。

Also, the app is only in landscape mode. The camera trigger button is on top right corner of the screen.

mediaPicker = [[UIImagePickerController alloc] init];
mediaPicker.allowsEditing = YES;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
                                                             delegate:self
                                                    cancelButtonTitle:@"Cancel"
                                               destructiveButtonTitle:nil
                                                    otherButtonTitles:@"Take photo", @"Choose Existing", nil];
    //[actionSheet showInView:self.view];
    [actionSheet showInView:self.navigationController.view];
}
// If device doesn't has a camera, Only "Choose Existing" and "Cancel" options will show up.
else {
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
                                                             delegate:self
                                                    cancelButtonTitle:@"Cancel"
                                               destructiveButtonTitle:nil
                                                    otherButtonTitles:@"Choose Existing", nil];
    [actionSheet showInView:self.view];
}

我需要动作表来显示按钮的位置。我应该怎么做呢。

I need actionsheet to show up where the button is. How should I go about it.

推荐答案

IPAD有一些关于 actionsheets 的特殊规则及其取消按钮,它通常取决于您从

IPAD have some special rules about actionsheets and their cancel buttons, it usually depends on where you are displaying the actionsheets from

显示操作表的位置。您可以显示<$ c中的操作表$ c> UIToolbar , UITabBar UIBarButtonItem ,或来自的UIView 。在确定如何呈现操作表时,此类将起始视图和当前平台考虑在内。对于在iPhone和iPod touch设备上运行的应用程序,操作表通常从拥有视图的窗口底部向上滑动。 对于在iPad设备上运行的应用程序,操作表通常显示在以适当方式锚定到起始视图的弹出框中。弹出窗口外的点击会自动关闭操作表,任何自定义按钮内的点击都会自动关闭。您也可以通过编程方式解除它。

You can show an action sheet from a UIToolbar, UITabBar,UIBarButtonItem, or from a UIView. This class takes the starting view and current platform into account when determining how to present the action sheet. For applications running on iPhone and iPod touch devices, the action sheet typically slides up from the bottom of the window that owns the view. For applications running on iPad devices, the action sheet is typically displayed in a popover that is anchored to the starting view in an appropriate way. Taps outside of the popover automatically dismiss the action sheet, as do taps within any custom buttons. You can also dismiss it programmatically.

在iPad上显示操作表时,有时您不应该包含取消按钮。如果仅显示操作表,系统将在不使用动画的情况下在弹出框中显示操作表。由于弹出窗口外的水龙头在不选择项目的情况下关闭操作表,因此这将导致取消工作表的默认方式。因此,包括取消按钮只会引起混淆。但是,如果您有一个现有的弹出框并且正在使用动画在其他内容上显示一个操作表,则取消按钮仍然是合适的

When showing an action sheet on iPad, there are times when you should not include a cancel button. If you are presenting just the action sheet, the system displays the action sheet inside a popover without using an animation. Because taps outside the popover dismiss the action sheet without selecting an item, this results in a default way to cancel the sheet. Including a cancel button would therefore only cause confusion. However, if you have an existing popover and are displaying an action sheet on top of other content using an animation, a cancel button is still appropriate

而不是使用 showInView 尝试使用以下方法之一

instead of using showInView try using from one of these method

[actionSheet showFromBarButtonItem:barItem animated:YES];

解释是 here & 此处

这篇关于在ipad上的动作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆