Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-27-2011, 04:10 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 6
omerv is on a distinguished road
Default Changing device orientation only when in specific ViewConrtroller inside Tab Bar app

Hi,

I have a tab bar application with 5 tabs.

Most of the application is in portrait mode and shouldn't change when the device orientation changes.

I do need to achieve this change "only" in 2 places.
In the first tab I have a navigation controller consisting of a table view with 2 rows.
Clicking each row pops a different (new) view controller.
These 2 view controllers are the only places in my app that require "special" actions when the device changes orientation, meaning a totally new view for some of the elements in them (which I achieved).

I am having 2 problems:

1. I can only get the whole application to rotate, including the tab bar.
For this, as suggested here I added this category addition code to my MainAppDelegate:
Code:
@interface UITabBarController (MyApp)
@end

@implementation UITabBarController (MyApp) 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return (toInterfaceOrientation == UIInterfaceOrientationPortrait ||
			toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
@end
As stated, I want the entire app to always stay in portrait mode but those 2 places, and them only. Can this be done? I understand the tab bar controller is the root controller of the entire app, but can I somehow control the action/no action for device orientation change when inside the different tabs and even further - their children?

2. In those 2 places I need the landscape view to take over the entire screen, including the bottom of the screen being used for the tab bar.
As I see when rotated right now, my new view is placed "under" the tab bar.

Thank you very much,


omerv
omerv is offline   Reply With Quote
Old 01-27-2011, 04:14 PM   #2 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 57
nexirius is on a distinguished road
Default

You can detect which tab is clicked and then return NO instead of YES!

Code:
NSInteger currentTab = getTab.tabBarController.selectedIndex;

if(currentTab==0) 
   do this
else 
   do that
Make sure you have properly referenced tabBarController.
nexirius is offline   Reply With Quote
Old 01-27-2011, 04:43 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 6
omerv is on a distinguished road
Default

Thanks nexirius! Indeed some progress.

I've added this:
Code:
@implementation UITabBarController (MyApp) 
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
	if(self.selectedIndex==0) 
		return (toInterfaceOrientation == UIInterfaceOrientationPortrait ||
			toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);
	else
		return NO;
}
@end
I now narrowed it down to the specific tab, but I still get this entire tab to rotate, including its first view which I don't want to rotate.

I'm also left with the full screen vs. the tab bar issue.

Thanks for your help,

omerv
omerv is offline   Reply With Quote
Reply

Bookmarks

Tags
device orientation, tab bar application, view controller

Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 358
15 members and 343 guests
7twenty7, blasterbr, Clouds, dre, EvilElf, iAppDeveloper, jeroenkeij, jimmyon122, Mah6447, Morrisone, n00b, pungs, Sami Gh, stanny, toon4413
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,121
Posts: 402,900
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:45 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0