2014-03-04 85 views
0

這裏是新鮮和綠色的新手。我剛開始編程,並且已經被UIAlert卡住了。我在這個網站上搜索過,但是有很多帖子,而且我說我對這些都有點新鮮,所以我不知道該找什麼。這是我的。UIAlert不顯示

-(void)showError { 
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" 
               message:@"Please try again later. Have a nice day." 
               delegate:nil 
             cancelButtonTitle:@"Dismiss" 
             otherButtonTitles:nil]; 
} 
+0

你需要調用'[警報顯示]'如果你想實際顯示警報。 – rmaddy

+1

在發佈像這樣的問題之前,請閱讀'UIAlertView'的文檔。 – rmaddy

+0

您是否搜索過它;即使在SO?因爲有很多UIAlertView的問題和答案。並遵循@ rmaddy的建議。 :) – Rashad

回答

0

[警報顯示]

我總是忘記這一點。快樂編碼。

1

需要做

[alert show]; 

呈現

1

代碼應該是:

-(void)showError { 
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" 
               message:@"Please try again later. Have a nice day." 
               delegate:nil 
             cancelButtonTitle:@"Dismiss" 
             otherButtonTitles:nil]; 
[alert show]; 
[alert release]; 
} 
0

- (無效)showError {

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" 
            message:@"Please try again later. Have a nice day." 
            delegate:nil 
            cancelButtonTitle:@"Dismiss" 
            otherButtonTitles:nil]; 

    [alert show]; 

}