我試圖在按任意一個按鈕(1 & 2)後保持此UIAlertView
。仍然關閉警報
一旦我的「+」按鈕或按「 - 」鍵,我可以看到UILabel
文本增量,那麼它會關閉UIAlertView
。
這是我目前使用的是什麼:
#pragma Alert View Methods
-(void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated
{
[self dismissWithClickedButtonIndex:buttonIndex animated:animated];
}
#pragma count functions
-(void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1 || buttonIndex == 2) {
return;
}
else{
[self dismissWithClickedButtonIndex:buttonIndex animated:YES];
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
self.currentCountButtonCount++;
[self.countAlert setMessage:[NSString stringWithFormat:@"%d",self.countButtonCount + 1]];
}if (buttonIndex == 2) {
self.currentCountButtonCount--;
[self.countAlert setMessage:[NSString stringWithFormat:@"%d",self.countButtonCount - 1]];
}
}
- (IBAction)countClick:(id)sender {
// 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];
}
在我的最後一個問題,有人告訴我,定製做出來,這是什麼現在我嘗試,它仍然駁回UIAlert。
我怎樣才能保持它的標籤更改,直到他們觸摸結束按鈕?
我會覆蓋哪些方法? @BaZinga – Keeano
你根本不應該覆蓋警報。 – Sulthan
@KeeanoMartin看到我編輯的答案 – KDeogharkar