Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 1, 2008, 09: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, 09: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, 10: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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Danger signs to be on the lookout for when buying a 3GS on Craigslist for unlocking? Granitel Jailbreaks and iOS Hacks 5 Nov 13, 2011 07:28 AM
What video recorder application works on the iPhone 3G iOS 4.2.1? Granitel iPhone and iPod touch Apps 5 Oct 31, 2011 12:17 PM
Will Verizon iPhone 4 CDMA cases work on the iPhone 4S? ijustgraduated iPhone Accessories 1 Oct 4, 2011 03:12 PM
HELP: The Status Bar rotates on the lockscreen and gets stuck brinycbri Jailbreaks and iOS Hacks 1 Nov 30, 2010 01:13 PM
Can you or why can't you rotate pictures on the iphone mashinhead iPhone 2 Feb 13, 2009 06:38 PM


All times are GMT -5. The time now is 08:50 AM.

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

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