Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically determine the size of an iPad modal view

I've got an iPad application which presents a modal view. I'd like to do some programmatic manipulation of the modal view's controls, but I can't find the way to get the modal view's size. If I call View.Bounds or View.Frame it gives me the bounds/frame for the whole screen (i.e. 1024x768) - but I know from measuring myself that the modal view is actually about 540x620.

While I know I can hard-code this in myself, this makes me feel dirty... is there a programmatic way for a modal view to get its own 'real' size?

Thanks

John

like image 823
John Avatar asked May 18 '11 06:05

John


2 Answers

Thanks. The problem was actually that I was trying to get the size in the ViewDidLoad method, rather than ViewDidAppear (that one always gets me...). In ViewDidLoad it was returning the 1024x768 size, but when I moved my code into ViewDidAppear, it started returning the correct (540x620) size!

like image 191
John Avatar answered Sep 20 '22 18:09

John


Have you tried setting modalPresentationStyle?

modalController.modalPresentationStyle = UIModalPresentationFormSheet;

Then you should get the correct frame size (540 x 620) from modalController.view.frame.

like image 42
Deepak Danduprolu Avatar answered Sep 22 '22 18:09

Deepak Danduprolu