Re: UIAlertView has zero bounds
Re: UIAlertView has zero bounds
- Subject: Re: UIAlertView has zero bounds
- From: Roland King <email@hidden>
- Date: Mon, 20 Apr 2015 18:54:25 +0800
>
> I wrote a separate app with just one button that brings up a
> UIAlertView. In the production code I create a UITextField then
> center it in the UIAlertView.
>
> - (void) willPresentAlertView: (UIAlertView *) alertView
> {
> CGRect bounds = alertView.bounds;
> NSLog( @"%f %f", bounds.size.width, bounds.size.height );
>
> return;
> }
My two comments would be that
1) willPresentAlertView: doesn’t make any promises about what state or size the UIAlertView is in when that method is called. Perhaps it used to be that the bounds were set on them at that point, but I don’t see any way to guarantee you can rely on that. One possibility could be that the views used to be sized and placed in code and now they are just given to autolayout to deal with, that could explain why the size is still zero before the view is presented, probably hasn’t been added to the window yet.
2) "The view hierarchy for this class is private and must not be modified”. In the strictest sense adding a UITextField to the UIAlertView is modifying the view hierarchy and thus something which you probably shouldn’t be doing.
So yes iOS8 likely broke something which wasn’t really guaranteed to work, but just happened to in previous iOSes.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden