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?
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];
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With