Is it possible to create multiple view or window in a (Window based) iPhone app ? If possible Plz tell me.
+1
A:
Yes kind of possible. Just create a new view using a view controller and create an instance of that view in your class. Then in an ibaction you could do some removing and adding subviews. That's just a quick and easy way tho, you can get into a lot more detail with how you would manage each view, etc.
Edit on Request: In your class, you would create an instance of it in the interface like so:
MyClass *myClass; (make sure to alloc and init in the init or awakeFromNib method)
Then make an instance of the app delegate in the ibaction like this:
MyAppDelegate *myAppDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
And then you can do this to switch from one view to another:
[self removeFromSuperView]; (or self.view in case this is a view controller)
[[myAppDelegate window] addSubview:myClass];
simplyharsh
2009-02-24 10:12:50
thanks for ur answer. can u give me some example or sample code?
Nahid
2009-02-24 10:21:11
+1
A:
In the Xcode documentation there's a book called "View Controller Programming Guide for iPhone OS" - that will help you.
Graham Lee
2009-02-24 10:35:25
A:
You can do sth like that to add view programatically,
//If you create controllers via XCode, just link them in the .h file with IBOutlet
UIViewController *aViewController = [[UIViewController alloc] initWithNibName:@"YourNibName" bundle:[NSBundle mainBundle]];
self.viewController = aViewController;
[aViewController release];
// Add the view controller's view as a subview of the window
UIView *controllersView = [viewController view];
[window addSubview:controllersView];
[window makeKeyAndVisible];
dkberktas
2009-11-02 14:47:11