警报视图位置不是中心

Nat*_*ang 6 uialertview ios ios7

我在UIView中有UIAlertView.当发生有关登录的错误时,将显示警报视图.

有时它会按照这张照片在中心位置上工作.

在此输入图像描述

我的代码

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login Failed" message:exceptionString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
[alert show];
Run Code Online (Sandbox Code Playgroud)

但有时它会在这张图片后面的左侧位置上工作.

在此输入图像描述

我只想要中心位置.

如何解决它.谢谢.

Ben*_*ery 1

您如何显示警报视图?你用这种风格设置框架吗initWithFrame

它应该类似于以下内容。

NSString *exceptionString = "something"; // where ever you get you failed message.

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Login Failed" message:exceptionString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];

[alert show];
Run Code Online (Sandbox Code Playgroud)