Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIALertView multiple buttons with text

I have an alertview with 3 buttons and text(label and NOT textView) If I jam it all together, it'll become ugly with this tiny scroll-text and all the buttons taking up most of the space. Does anyone know how to fix this?

like image 794
user1970792 Avatar asked Jan 11 '13 17:01

user1970792


2 Answers

Why don't you try to create a custom View for this.

You can use as you want to customize, size, color, background etc.

And show it as a modal window/view.


If you still want to use alertView then you can give spacing as:

UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Title" message:@"\n\n!\n\n\n\n" delegate:self cancelButtonTitle:@"Button 1" otherButtonTitles:@"Button 2",@"Button 3", nil];
[alert show];
like image 65
Anoop Vaidya Avatar answered Oct 01 '22 01:10

Anoop Vaidya


A simple way to move the text view down is to add a message

[alertViewObject setMessage:@"\n"];

THe reason for your frame isn't taking effect is that -show sets the frame and creates the view hierarchy before starting the animation. You should also make the text view the first responder so the keyboard pops up.

Customize your AlertView by using following Code.

// Customize Alert View
UIAlertView *alertView = [UIAlertView new];
alertView.title = @"Alert Title";


// Adding Your Buttons
[alertView addButtonWithTitle:@"Button1"];
[alertView addButtonWithTitle:@"Button2"];
[alertView addButtonWithTitle:@"Button3"];
[alertView addButtonWithTitle:@"Button4"];


// Add a Space for Text View
alertView.message = @"\n";


// View heirarchy, set its frame and begin bounce animation
[alertView show];


// Set the frame
CGRect frame = alertView.frame;
frame.origin.y -= 100.0f;
alertView.frame = frame;


// Adding TextField
UITextField* text = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];
text.borderStyle = UITextBorderStyleRoundedRect;
[alertView addSubview:text];
[text becomeFirstResponder]; 

I hope this will help you.

like image 30
Satish Azad Avatar answered Oct 01 '22 03:10

Satish Azad