Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 1, 2008, 10:15 PM   #1
cmorss
macrumors newbie
 
Join Date: Jul 2008
Replace UIView when rotating on the iPhone

Hello,

I've been attempting to replace one UIView with another when rotating the iphone. I can replace the one view for another via the following code, but the views "walk" off the containing view and get resized smaller:

The two views I'm switching are the current view in the navigation controller and a card view. The card view is what is displayed when the in portrait mode. I put a containing view for both the navView and cardView to be placed in the hopes that I could have more control. All views have their own controllers and everything was wired up in IB (animation code has been removed just get it to work):
Code:
- (void)toggleCardAndDeckView {

	UIView *navView = navigationController.view;
	UIView *cardView = cardViewController.view;
	UIView *baseView = baseViewController.view;

	if ([navView superview] == nil) {
		[cardView removeFromSuperview];
		[baseView addSubview:navView];
	}
	else {
		[navView removeFromSuperview];
		[baseView addSubview:cardView];
	}
}
The first time I rotate to the card view it looks okay. Moved down a bit but okay. When I then rotate back to the navView it gets allocated about 1/4 of the screen vertically. The next rotation is worse for both and finally they are no longer visible.

The rotation is triggered in the baseViewController (the container) via this:
Code:
- (void)willRotateToInterfaceOrientation: (UIInterfaceOrientation)toInterfaceOrientation 
	duration: (NSTimeInterval)duration {
	CardsAppDelegate *appDelegate = (CardsAppDelegate *)[[UIApplication sharedApplication] delegate];
	[appDelegate toggleCardAndDeckView];			
}
I tried it in the willRotateToInterfaceOrientation, willAnimateSecondHalfOfRotationFromInterfaceOrientation and didRotateFromInterfaceOrientation methods also with the same basic results.

My thoughts had been to set the new shown view's bounds to bounds of the container view, but the container view's bounds are always null!

I've seen this done before in videos so I know it works, but any help would be greatly appreciated.

Thanks,
Charlie
cmorss is offline   0 Reply With Quote
Old Apr 29, 2009, 10:58 AM   #2
brian.v
macrumors newbie
 
Join Date: Apr 2009
Hey, how did you end up resolving this? I see lots of posts asking the same questions but no real answers.

Thanks in adavance.
brian.v is offline   0 Reply With Quote
Old Apr 30, 2009, 11:37 AM   #3
cmorss
Thread Starter
macrumors newbie
 
Join Date: Jul 2008
Quote:
Originally Posted by brian.v View Post
Hey, how did you end up resolving this? I see lots of posts asking the same questions but no real answers.

Wish I could help, but I'm sorry to say that I've never figured it out. I ended up moving on to other things.

Charlie
cmorss is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
iPhone 5 - loose headphone jack, crackling when rotating plug...normal? cabingirl iPhone 8 Sep 6, 2014 08:36 AM
One Year Anniversary of 15" rMBP! Replace or not replace? ajcadoo MacBook Pro 18 May 28, 2013 09:07 PM
Photo App not rotating on iOS6/iPhone 5 SteveJobs2.0 iOS 6 0 Sep 22, 2012 09:25 PM
NEW Tri-Lens Rotating Lens Aluminum Case iPhone 4/4s/5 izzigadgets iPhone Accessories 3 Sep 2, 2012 02:06 PM
make uiview transparent without having the uiview's buttons transparent johnmerlino iPhone/iPad Programming 7 Jun 1, 2012 03:20 AM

Forum Jump

All times are GMT -5. The time now is 01:00 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC