PDA

View Full Version : UIAlertView




chhoda
Nov 17, 2008, 11:01 AM
Can I put more than 2 buttons in UIAlertView and customize them ? and specify different actions for all of them ?

regards
ch



jnic
Nov 17, 2008, 11:04 AM
Yes. (https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIAlertView_Class/UIAlertView/UIAlertView.html#//apple_ref/occ/instm/UIAlertView/initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:)

robbieduncan
Nov 17, 2008, 11:07 AM
You can add any number of buttons using initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles: (http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIAlertView_Class/UIAlertView/UIAlertView.html#//apple_ref/occ/instm/UIAlertView/initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:).

Your delegate will get the alertView:didDismissWithButtonIndex: (http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIAlertViewDelegate_Protocol/UIAlertViewDelegate/UIAlertViewDelegate.html#//apple_ref/occ/intfm/UIAlertViewDelegate/alertView:didDismissWithButtonIndex:) message when the alert is dismissed. You can use the passed index to perform any action you want...

dejo
Nov 17, 2008, 11:07 AM
Can I put more than 2 buttons in UIAlertView and customize them ?
Yes, you can. Check out the developer documentation on the UIAlertView initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles method.

...and specify different actions for all of them ?
Kinda. When you implement the UIAlertViewDelegate protocol for your delegate, you can have the different actions if you code them based on what button was clicked in the alertView:clickedButtonAtIndex: method.

chhoda
Nov 20, 2008, 07:37 AM
thanks a ton... but I think i wont be able to customise it because i wanted to put a customtableview in place of message

please correct me if i am wrong

i tried doing uialertview initwithframe:CGRectMake(0, 0, 400, 400);
[altV show];

it seems this width height is not honoured...

regards
ch

fenrus110
Nov 20, 2008, 01:26 PM
I don't think initWithFrame works for UIAlertView. It doesn't work for some other UIKit classes too, i'm sure. It's always meant to go in the centre of the screen.

If you wanted to adjust the X/Y coordinates, you could apply a tranform...