Showing/Hiding windows iPhone Dev
In my iPhone app I am developing, I have defined two windows:
@interface The_NoteAppDelegate : NSObject <UIApplicationDelegate> {
IBOutlet UIWindow *newNoteWindow;
IBOutlet UIWindow *homeWindow;
}
@property (nonatomic, retain) UI开发者_JAVA技巧Window *newNoteWindow;
@property (nonatomic, retain) UIWindow *homeWindow;
and they are linked correctly in IB - but how do I show/hide these windows?
[homeWindow makeKeyAndVisible];
works in appDidFinishLaunching
but when I try [newNoteWindow makeKeyAndVisible];
again to open the other window (on a button touch event) in front of the other, the app freezes.
I know this is a very n00by question but please help me out :)
I'd say this wasn't the normal approach. The usual "currency" is the view. Then you can swap views by adding and removing them as subviews to your main view. [self.view addSubView:otherview]
Also look at whether you should be using viewControllers for each thing you want to display, and making use of either the navigationController stack, or displayModalView.
In almost every instance, you don't want to have multiple instances of UIWindow
. Your application has its own window, and from there, you deal with views. For what you're trying to do (as far as I can tell from your variable names), it would make sense to use a UINavigationController
. Then write a UITableViewController
subclass for your home view, and a UIViewController
subclass for your notes view.
精彩评论