iPhone SDK: Add a new line on UIAlertView

March 25, 2009 § Leave a comment

To break a new line on initWithTitle and message on UIAlertView, you can add “/n”.

Add UIAlertViewDelegate to MainViewController’s interface
@interface YourViewController : UIViewController <UIAlertViewDelegate>

Add UIAlertView to a method

– (void)alertOKCancelAction {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@”UIAlertView”
message:@”<Alert message>”
delegate:self
cancelButtonTitle:@”Cancel”
otherButtonTitles:@”OK”, nil
];
[alert show];
[alert release];
}

Use NSLog to check response

– (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 0)
{
NSLog(@”ok”);
}
else
{
NSLog(@”cancel”);
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

What’s this?

You are currently reading iPhone SDK: Add a new line on UIAlertView at Web Builders.

meta

%d bloggers like this: