开发者

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, 开发者_Go百科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


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!


Have you tried setting modalPresentationStyle?

modalController.modalPresentationStyle = UIModalPresentationFormSheet;

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜