直接の(技術的な)質問に答えるのではなく、アプリストアでアプリを評価するためのアラートを実行しているようです。より大きな問題を解決しようとします。ユーザーにレビューを求めるプロンプトを処理するには、既存のオープンソースソリューションを検討する必要があります。ユーザーにプロンプトを表示するための起動/日数などの機能を制御できます。
ArashPyanのAppiraterをお勧めします。アプリの評価部分を自動的に処理します。ユーザーをアプリのレビューページに直接誘導し、非常にカスタマイズ可能です。新しい開発者のための最良の解決策!GitHubで入手できます。
demostheneseによるiRateも同様のソリューションですが、よりクリーンで、アプリの高速切り替えをサポートします。
代わりに、これらの「既成の」ソリューションを使用してください。自分で処理するよりもうまくいくはずです!機能をカスタマイズする方法に関するドキュメントとサンプルが含まれています。
余談ですが、Appleはユーザーにアプリケーションを評価させるためにAlertViewsを使用することを推奨していないと思います。上記のツールを責任を持って使用してください。ユーザーにすぐにプロンプトを表示しないでください。また、[永久に閉じる]ボタンが含まれていることを確認してください。
この問題の技術的な解決策を求めている場合(つまり、[永久に閉じる]ボタンを使用して起動時にプロンプトを表示する場合)、次の手順を実行する必要があります。
-(void)viewdidload{
//Access NSUSerDefaults and check a variable called launch
// launch's default value is 0
if (launch == 0) {
alert = [[UIAlertView alloc] initWithTitle:@"Rate!" message:@"You'll see this everytime you launch until you click Dismiss Forever" delegate:self cancelButtonTitle:@"Not Now" otherButtonTitles:@"Okay! ", @"Dismiss Alert and Don't Show it to me", nil ];
[alert show];
[alert release];
}
}
else
{
//nothing
}
//continue customizing
}
-(void)alertView:(UIAlertView *) alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0)
//Assume this is the Okay Button
{
//Now use NSUserDefaults and set a variable called launch to 1
// the default value for launch should be 0
// now that its set to 1
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"ILoveAlertViews.com" ]];
}
if (buttonIndex == 1) {
//assume this is the dismiss button
//Now use NSUserDefaults and set a variable called launch to 2
//2 means that they never want to see it. The AlertView should not be called on the next launch
}
}