Hi There, I would like to know that how to change UIAlert's cancel button text during runtime.
+5
A:
- (void)showAlertWithTitle:(NSString*)title message:(NSString*)message cancelButtonTitle:(NSString*)cancelTitle {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:title message:message delegate:self cancelButtonTitle:cancelTitle otherButtonTitles:nil];
[alertView show]
[alertView release];
}
aegzorz
2010-10-14 23:24:24
@aegzorz, thanks for your response, but I'm already initialized it with same constructor. Also it is possible to change message, title properties of UIAlerView if you assign it to local variable on your view or controller. The question is, is it possible to change cancel button title in any part of code ?
fyasar
2010-10-15 06:49:44
Well you set the cancel button title in the constructor, and that is in code. You can create the alert anywhere and just call show on it and then release it.
aegzorz
2010-10-15 07:47:45
You can not release it suddenly, if you are using delegate of it such as clickedButtonAtIndex:
fyasar
2010-10-15 08:21:12
When you call show on an UIAlertView it is added to UIWindow and retained, so you can safely release it after calling show. What you need to make sure is that the delegate is not released before the alert is dismissed.
aegzorz
2010-10-15 08:36:27