开发者

How to display custom modal UIView?

开发者 https://www.devze.com 2023-02-27 02:29 出处:网络
I am trying to display a custom UIView on top of all other views making it modal t开发者_JAVA百科hat works correctly in both portrait and landscape. The way i am currently doing this is by creating a

I am trying to display a custom UIView on top of all other views making it modal t开发者_JAVA百科hat works correctly in both portrait and landscape. The way i am currently doing this is by creating a transparent black view which basically dims the entire screen and then add my custom view on top of that. Everything is working great except for the fact that it doesn't orient itself property when in landscape. I think this is due to the way i am adding my view:

UIWindow* mainWindow = (((MyAppDelegate*)[UIApplication sharedApplication].delegate).window);   
[mainWindow addSubview:self];

It seems that mainWindow is ALWAYS in portrait regardless of what the actual device orientation is so even when i am in landscape my custom view displays upside down as if it was in portrait mode. My main viewcontroller is a navcontroller which adds several custom views on top of it so i really dont want to pass a reference to it all the way down through my views just so i can use it above.

My question finally is how do i correctly add my custom view to the main windows so that it is correctly orientated in landscape as well as portrait and still displays over the entire screen.

Thx


Create and make-key a new UIWindow with a higher zorder, and add a view controller to it. The view controller has the built in logic to handle view rotation.

0

精彩评论

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