使 UIAlertView 成为 popOverView

Making UIAlertView a popOverView

我有一个 UIAlertView,但我希望它像这样显示:

不是像这样在底部:

请注意:我只会有文字,没有任何按钮。

这是我的代码:

- (IBAction)myButton:(id)sender
{
    UIAlertController *alertCtrl = [UIAlertController alertControllerWithTitle:@"Hello" 
                 message:nil 
                 preferredStyle:UIAlertControllerStyleActionSheet];

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

我可能需要类似 UIPopOver 的东西,带有箭头方向。

您必须实施 UIPopoverController,并使其看起来像 UIAlertView。弹出窗口将是一个 UIViewController,您必须对其进行自定义,使其看起来就像您想要的那样。

这里有一个很好的教程:Introduction to UIActionSheet and UIPopoverController