开发者

iphone, multiple uiwindows in one iphone application

hi I am an iphone newbie, so a little confused in UIWindow concept. On Mac, we can use multiple NSWindows in one application, i guess. But in iphone, can we use multiple UIWindows in one iphone application. To be very specific, i have 3 xib files i开发者_StackOverflow中文版n my application: 1. MainWindow.xib 2. ViewController (coupled with appDelegate) 3. MyCustomViewController... wherein i want to use UIwindow and multiple views with that window.

Now my question is that i am already using UIWindow in MainWindow.xib, can i use use another UIWindow in MyCustomeViewController.xib???

Best regards


You don't need and shouldn't use several windows on iPhone according to the documentation.

What you need is to change view controllers currently present on the screen.

From you ViewController you can take to ways to present MyCustomViewController: 1. Employ UINavigationController's method - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated if case you put your ViewController inside a navigation controller.

  1. Use - (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated method of UIViewController class.

something like below inside you ViewController methods:

MyCustomViewController *vc = [MyCustomViewController new];
[self presentModalViewController: vc animated: YES];
[vc release];

see "View Controller Programming Guide for iOS" for exhaustive discussion: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html


You do not need to use another window just keep swapping views on the available UIWindow & you'll be fine.


This is not the standard approach for iOS apps.

If you still want to do it see this answer

Advantages, problems, examples of adding another UIWindow to an iOS app?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜