私のクライアントプロジェクトUIAlertView
では、ボタンを押すだけで作成する必要があります。その部分は難しくなく、上記のコードでそれを行いました:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
self.currentCountButtonCount++;
}if (buttonIndex == 2) {
self.currentCountButtonCount--;
}
}
- (IBAction)countClick:(id)sender {
//self.alertMessage = [[NSString alloc]init];
// tallies and keeps current count number
if (!self.currentCountButtonCount)
self.currentCountButtonCount = 0;
NSString *alertMessage = [NSString stringWithFormat:@"%d", self.countButtonCount];
self.countAlert = [[UIAlertView alloc]initWithTitle:@"Count" message:alertMessage delegate:self cancelButtonTitle:@"end" otherButtonTitles:@"+",@"-", nil];
[self.countAlert show];
}
問題なく動作することがわかりますが、それは私が達成しようとしていたものではありません。
私が必要とするのはUIAlertView
、ユーザーが + ボタンを押したときにインクリメントされた文字列に変更されUIAlertViews
、 - ボタンが押されたときに減少した値を表示するメッセージです。
上記のコードでこれができると思いましたが、ボタンが押されたときにアラートを閉じるだけです。ユーザーのカウントが完了するまでアラートを維持する必要があります。
これをどのように実装しますか?
カスタムを試してみましたUIAlertView
が、実際にはグラフィック面でのみ役立つようです。