Pregunta

When creating an UIAlertView in code, the frame and bounds aren't calculated, yet. But even in the delegate method willPresentAlertView, there are still just zeros in the CGRects. Is there a way to determine an UIAlertView's size, or - as I only need its width - is the width of the view predetermined by iOS and the device?

¿Fue útil?

Solución

In the comments you mention you want to add custom subviews to your alert. I wouldn't recommend this approach, but look at an alternative such as SDCAlertView (full disclosure: I wrote it).

In any case, the width of an alert is 270 points.

Otros consejos

From the Apple Documentation:

The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified.

Basically, if you need to add elements, you should create your own UIAlertView look-alike. The system class is intended for a very limited range of functionality.

I was wondering about this information too since I am wanted to create a view the same size. The size of the alert style alert for iOS 7-9 is:

{ 270, 144 }

i.e. (270 width x 144 height)

I have not tested this on ever device, so there may be some discrepancy, will update if I ever get around to testing them all.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top