Dear Cocoa users, I'm trying to implement view switching based on the view switching example in Hillegass. I have a main window with a box that contains other views. The following method, in the view controller class for the main window, switches the views contained in the box and resizes the box to fit the new view.
-(void)displayViewController:(NSViewController *)vc { //Try to end editing NSWindow *w = [box window]; BOOL ended = [w makeFirstResponder:w]; if(!ended) { NSBeep(); return; } NSView *v = [vc view]; //Compute the new window frame NSSize currentSize = [[box contentView] frame].size; NSSize newSize = [v frame].size; float deltaWidth = newSize.width - currentSize.width; float deltaHeight = newSize.height - currentSize.height; NSRect windowFrame = [w frame]; windowFrame.size.height += deltaHeight; windowFrame.origin.y -= deltaHeight; windowFrame.size.width += deltaWidth; //Clear the box for resizing [box setContentView:nil]; [w setFrame:windowFrame display:YES animate:YES]; //Put the view in the box [box setContentView:v]; } I have a routine that I want to run after the view is finished switching and all the UI elements for the new view are loading. The trouble I'm having is that if I call a routine after calling displayViewController to change the view things happen in this order: 1. The main window and the box resize to fit the view I am swapping in but after the resizing is complete, the box is empty and none of the UI elements (e.g label, progress bar, etc...) contained in the new view are visible. 2. The routine I call after displayViewController runs. 3. The UI elements of the new view become visible. I need to find a way to swap the order of steps 2 and 3. I have tried using the awakeFromNib in the view controller for the new view but any code I put in the awakeFromNib method of the new view's view controller also runs before the UI elements of the new view become visible. Using the debugger I have noticed that the UI elements only appear after control reaches [NSApplication -run] near the top of the call stack (pardon me if that sentence did not make sense, I am a mechanical engineer by training). I would like to know if there is any way I can receive a notification after the UI elements in the view are visible so that I can wait until that happens before running a routine. I would be very grateful for any insight on this problem. Thanks, Alec Alec M. Stewart President Velocitek - Performance Training Tools Web: www.velocitek.com Toll free USA & Canada: 1-800-693-1610 Australia: 02-8006-8949 ex. 1 Worldwide: +1-(650)-362-0499 ex. 1 Fax: +1-(650)-618-2679 Skype: alec_stewart Address: 271B Kahiko Street, Paia, HI, 96779, USA twitter.com/alecms facebook.com/alec.stewart linkedin.com/in/alecms _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com