Shivomkara Chaturvedi
Shivomkara Chaturvedi

Reputation: 1697

Highlight the first button in a UIAlertView

I am developing an iPad application. I have an alert box with two buttons, "YES" and "NO".

alert=[[UIAlertView alloc] initWithTitle:@"Confirmation!" 
                                 message:@"Would you like to continue placing the order ?" 
                                delegate:self 
                       cancelButtonTitle:@"YES" 
                       otherButtonTitles:@"NO", nil];
alert.tag=100;
[alert show];
[alert release];

In the alert box, the "YES" button is dark and "NO" is highlighted, but I want the reverse. Is there any way to do this?

Upvotes: 0

Views: 1798

Answers (2)

utsabiem
utsabiem

Reputation: 920

Switch your 'YES' and 'NO'. Though you have used in in many places and added functionality, I don't think it will be of much trouble ... In this method : didDismissWithButtonIndex, just switch the index, i.e, if you wrote the functionality of 'YES' in button index 1, change it to 0 in the if condition : if(buttonIndex==0) { //Do job for NO }
else {//Do job for YES}
Enjoy !! :)

Upvotes: 1

Minakshi
Minakshi

Reputation: 1433

When you add cancel button it shows in dark and other button in light color. So if you want NO button in dark declare it as cancel button. You can refer the tutorial for this

http://mobile.tutsplus.com/tutorials/iphone/uialertview/

Upvotes: 0

Related Questions