[英]Custom UIAlertView, Message Change on delegate
在我的客戶項目上,我需要在按下按鈕時創建一個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];
}
您將看到沒有缺陷的有效方法,但這不是我想要實現的目標。
我需要的是,當用戶按下UIAlertViews
+按鈕時, UIAlertView
的消息更改為遞增的字符串,並在按下-按鈕時顯示減小的值。
我以為上面的代碼可以做到這一點,當按下任何按鈕時,它只是關閉警報。 我需要它來保持警報狀態,直到用戶完成計數為止。
我將如何實施呢?
我嘗試了一個自定義的UIAlertView
但它似乎實際上僅對圖形方面有所幫助。
您可以使用自定義UIView
創建一個CustomAlertiew
,然后為該CustomAlertiew創建delegates
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.