Monotouch - UIActionSheet无法在iPad上正确显示

Sho*_*gan 2 mono xamarin.ios uiactionsheet ipad

我有一个UIActionSheet,可以在iPhone模拟器上正常工作.它在用户触摸UIButton时显示.

使用iPad,我相信UIActionSheets被包装到UIPopupController中.

当我使用iPad模拟器调用相同的代码时,我会看到一个很薄的"线",看起来像UIPopupController(你可以看到通常指向控件的小箭头).没有任何内容可以看到.

使用带有MonoTouch的iPad使用UIActionSheet的正确方法是什么?以下是我一直在测试的一些示例代码 - 创建UIActionSheet:

var actionSheet = new UIActionSheet () { Style = UIActionSheetStyle.BlackTranslucent };
        actionSheet.Frame = actionSheetFrame;
        actionSheet.Clicked += (s, e) => { Console.WriteLine ("Clicked on item {0}", e.ButtonIndex); };
actionSheet.AddSubview (doneButton);
Run Code Online (Sandbox Code Playgroud)

然后,我通过从按钮调用以下内容来显示操作表:

btnSay.TouchUpInside += (sender, e) => {
            actionSheet.ShowFrom(tmpBtn.Frame, tmpView, false);
        };
Run Code Online (Sandbox Code Playgroud)

使用iPad模拟器时,我得到了附带的截图.

iPad UIActionSheet示例

作为参考,这是使用iPhone模拟器时UIActionSheet的样子.

iPhone UIActionSheet示例

注意:该项目是一个通用的单视图MonoTouch c#项目.

任何指针或帮助将不胜感激!

Dar*_*bio 6

最近我发布到应用程序商店的应用程序遇到了同样的问题.

当你UIActionSheet在iPad上展示时,iOS包装了UIActionSheet一个UIPopoverView.

我使用以下代码来检测这是否是iPad,如果是,请调整弹出视图的框架:

const int CHROMEWIDTHLEFT = 9;
const int CHROMEWIDTHRIGHT = 8;
const int MARGIN = 50;

UIActionSheet _actionSheet;

...

if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) {
    var popover = _actionSheet.Superview.Superview;
    if (popover != null)
    {
        var x = _actionSheet.Frame.X + MARGIN;
        var y = (UIScreen.MainScreen.ApplicationFrame.Height - _actionSheet.Frame.Height) / 2;
        var width = _actionSheet.Frame.Width - (MARGIN * 2);
        var height = _actionSheet.Frame.Height;

        popover.Frame = new RectangleF (x, y, width, height);
        _actionSheet.Frame = new RectangleF (x, y, width - (CHROMEWIDTHLEFT + CHROMEWIDTHRIGHT), height - (CHROMEWIDTHLEFT + CHROMEWIDTHRIGHT));
    }
}
Run Code Online (Sandbox Code Playgroud)

这个例子是基于Xamarin ActionSheet日期选取器在这里

我把它们作为一个要点(Normal和DatePicker)