我试图在按任意一个按钮(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