Objective-C UIAlertController to Show DialogBox (Alert Box) with Multiple Buttons

Malisha Tharindu
1 min readAug 11, 2020

--

objective C UIAlertViewController

#objectiveC #UIAlertViewController #iOSDevelopment

Here I use UIAlertController to make an alert/dialog box.

//Initialize UIAlertController and its title and subtitle
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@”Tittle” message:@”Subtitle” preferredStyle:UIAlertControllerStyleAlert];
//Button 1
UIAlertAction *actionButton1 = [UIAlertAction actionWithTitle:@”Button1” style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//code for performing acctions to be excuted when click Button1
NSLog(@”Button 1 Pressed”);
}];//Button 2
UIAlertAction *actonButton2 = [UIAlertAction actionWithTitle:@”Button2” style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//code for performing acctions to be excuted when click Button2
NSLog(@”Button 2 Pressed”);
}];[alert addAction: actonButton1];[alert addAction: actonButton2];[self presentViewController:alert animated:YES completion:^{//code for performing acctions to be excuted when UIAlertController is startedNSLog(@”dffefe”);}];

you can Implement this code block inside action or function.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Malisha Tharindu
Malisha Tharindu

Written by Malisha Tharindu

Entrepreneur | iOS Developer | Web Developer with more than 5 Years of Experience. Founder of Learn with Malisha

No responses yet

Write a response