2014-03-05 52 views
6

我在UIView中有UIAlertView。當出現關於登錄的錯誤時,將出現警報視圖。警報查看位置不是中心

有時它在中心位置在這張照片後面工作。

enter image description here

我的代碼

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

但有時它這張照片下面的工作對左側位置。

enter image description here

我想只有中心的地位。

如何解決它。謝謝。

+1

發表您的相關代碼 – codercat

+0

我用同樣的代碼... UIAlertView中*警報= [[UIAlertView中頁頭] initWithTitle:@ 「登錄失敗」 消息:exceptionString代表:無cancelButtonTitle:@ 「OK」 otherButtonTitles :無]; [alert show]; –

+0

您是否爲alertView設置了任何框架? –

回答

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]; 
+0

我使用相同的這段代碼,但是發生了這種情況。 –

+0

您是否有其他可能會改變警報視圖的代碼?任何轉換警報?這是發生在模擬器和設備還是模擬器? –

+0

如果這是一個瑕疵,那麼你應該像這樣離開它。我已經出去了。 – DCMaxxx

0

這可能如果您使用的變換

alert.transform = CGAffineTransformMakeTranslation(x, y); 
0

@NatthawatSudsang我以前看過這將發生,當你調用UIAlertView中多次發生。

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

//then some code 
//more code 

[alert show];