iOS5: Has somebody managed to fix UIAlertView with

2019-06-25 08:43发布

问题:

Apple really screwed this one up. I want to use a UIAlertView with the new UIAlertViewStylePlainTextInput style and have three buttons in it. The result looks as follows:

Has somebody managed to build a workaround until Apple will have fixed this issue? Maybe reducing the button height somehow or increase the total height of the alert view?

回答1:

This is not a complete solution but it may get you started.

UIAlertView view = new UIAlertView ("Alert", "This is an alert\n\n\n", null, "Login", "One", "Two");

UIView theTextField = new UIView (new RectangleF (12.0f, 80.0f, 260.0f, 25.0f));
UITextView txt = new UITextView (new RectangleF (0f, 0f, 260.0f, 25.0f));
txt.BackgroundColor = UIColor.White;
theTextField.AddSubview (txt);
view.AddSubview (theTextField); 

view.Show ();

I observed that the AlertView tries to be intelligent when you add a text view as a sub view. But if you put a generic UIView in as a container it gives you something more useable.

I also verified that this is a problem in XCode.

This post may give you some more ideas.