2010-09-30 42 views
0

我對iPhone編碼相當陌生,想知道是否有人可以幫助我。UIAlert for review頁面

已經得到了代碼準備,這樣當應用程序加載UIAletView負載,並提示用戶檢查/速率的應用程序,但我有一個名爲「永不率」

我需要幫助找出如何按鈕編碼「從不評分」按鈕,以便在每次加載應用程序時不會加載UI警報。

這是我到目前爲止的代碼:

(void)viewDidLoad { 


UIAlertView *alert; 
alert = [[UIAlertView alloc] initWithTitle:@"Rate My Appication" message:@" Please Rate my Application and check out my other Apps" 
      delegate: self 
     cancelButtonTitle:@" Cancel " 
     otherButtonTitles: @" Rate Now ", @"Check Other Apps", @" Never Rate ", nil]; 

[alert show]; 
[alert release]; 
} 

(bool)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 

// Never Review Button 
if (buttonIndex == 3) 
{ 


} 

// Review Button 
else if (buttonIndex == 1) 
{ 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/gb/app/calculator/id389197581?mt=8"]]; 
} 

// Other Apps Button 
else if (buttonIndex == 2) 
{ 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.com/apps/2headsolutions"]]; 
} 

} 

回答

6

你可以在磁盤上存儲的某處一個布爾標誌。然後下一次,您檢查neverRate == NO並相應地顯示警報。

您可以存儲此使用NSUserDefaults的:

[[NSUserDefaults standardDefaults] setBool:YES forKey:@"neverRate"]; 

然後檢索它:

BOOL neverRate = [[NSUserDefaults standardDefaults] boolForKey:@"neverRate"]; 
if(neverRate != YES) { 
    //Show alert here 
} 
0

這是我到目前爲止的代碼:

- (void)viewDidLoad { 

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Rate My Appication" 
               message:@" Please Rate my Application and check out my other Apps" 
               delegate:self 
             cancelButtonTitle:@" Cancel " 
             otherButtonTitles: @" Rate Now ", @"Check Other Apps", @" Never Rate ", nil]; 

    [alert show]; 
    [alert release]; 
} 

- (bool)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 

    // Never Review Button if (buttonIndex == 3) { 

    //} 

// Review Button else if (buttonIndex == 1) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/gb/app/calculator/id389197581?mt=8"]]; } 

// Other Apps Button else if (buttonIndex == 2) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.com/apps/2headsolutions"]]; } 

} 
+0

請格式化你的代碼,這僅僅是不可讀。此外,您應該更新您的問題,而不是發佈答案。 – Rengers 2010-10-02 15:57:04

0

Rengers是正確

嘗試使用NSUserDefaults

保存

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; 

// saving a BOOL 
[prefs setBool:BOOL_var forKey:@"RATE_KEY"]; 

[prefs synchronize]; 

閱讀

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; 

// getting a BOOL 
BOOL var = [prefs boolForKey:@"RATE_KEY"]; 

Check This link