Discussion Forums  >  Xcode, Errors, Installing, Configuring

Replies: 8    Views: 4089

Lester
buzztouch Evangelist
Profile
Posts: 17
Reg: Aug 12, 2011
Florida
10,670
09/13/12 09:04 PM (11 years ago)

Rotation Broken on Xcode 4.5 and iOS 6

Landscape view doesn't seem to work when building with Xcode 4.5 and iOS 6. I suspect the issue involves this from the iOS 6 release notes: "Autorotation is changing in iOS 6. In iOS 6, the shouldAutorotateToInterfaceOrientation: method of UIViewController is deprecated. In its place, you should use the supportedInterfaceOrientationsForWindow: and shouldAutorotate methods. More responsibility is moving to the app and the app delegate. Now, iOS containers (such as UINavigationController) do not consult their children to determine whether they should autorotate. By default, an app and a view controller’s supported interface orientations are set to UIInterfaceOrientationMaskAll for the iPad idiom and UIInterfaceOrientationMaskAllButUpsideDown for the iPhone idiom...." There's a thread on Apple's Dev Forums about it here: https://devforums.apple.com/thread/166544?tstart=30 I tried implementing the fixes recommended there and the app builds, but still no rotation [and I have no idea what I'm doing]. Trying to get updates for iPhone 5 submitted, but it would suck to lose rotation.
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
09/13/12 11:36 PM (11 years ago)
I love this: "and I have no idea what I'm doing" good stuff. For sure there will be other issues we'll need to work out as iOS 6 is released. This happens with every new iOS version but always works out. I've added this one to the list already and look forward to getting a solution engineered. Hang in there, it gets easier!
 
Lester
buzztouch Evangelist
Profile
Posts: 17
Reg: Aug 12, 2011
Florida
10,670
like
09/14/12 12:24 AM (11 years ago)
Thanks for the response David. I was hoping there could be a "quick fix" that could be implemented in the meantime for rotation as everything else is working great for my apps. I've seen it suggested several places that appdelegate's window.rootViewController needs to be set in didFinishLaunching and orientation then works as before. For my tabbed application something like this: window.rootViewController = tabBarController; Btw, what an incredible product you have here. It's truly magical how complex and sophisticated buzztouch is, yet so simple. Then you give us the source code? What!
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
09/14/12 01:02 AM (11 years ago)
thanks for the kind words. I too hope there is a simple solution. I haven't looked into this at all but have started looking into some other gotchas. Are you building for iPhone and iPad or just one? I'm asking because I'll keep this thread in mind while I dig around. If it's an easy fix, and we're not ready to roll out the fix (with others I'm sure) I'll gladly send it your way. In the meantime, it may be easier than it appears to get this to work? Your app controls it's rotation in only a few files. Have a look in the BT_layout folder. The files that handle all this stuff are called BT_rotatingNavController and-or BT_rotatingTabBarController If your app doesn't use tabs, you won't be using the BT_rotatingTabBarController file but it will still be included in your project (in case you add tabs later after compiling). There are several related methods in these files: -(void)willRotateToInterfaceOrientation -(void)didRotateFromInterfaceOrientation -(void)willAnimateRotationToInterfaceOrientation -(BOOL)shouldAutorotateToInterfaceOrientation Some of these are deprecated in iOS 6. This means you'll need to work out a strategy to suppress the Warnings (yellow) that Xcode generates because it doesn't think you should use the methods anymore. We can discuss these ideas later and you can compile with warnings while you work through this. In the meantime...un-comment each of the BT_debugger method calls in each of these methods. The BT_debugger is the awesome class we setup that outputs hundreds of very helpful lines of text in the Console when the app is running and connected to Xcode. This is super useful in times like this. Uncomment the lines, then run the app, rotate that thing...the console will explain to you what methods are firing / not firing. You'll need to have this knowledge before knowing what to fix, change, update, etc. Tip: You can rotate the simulator to do this, you don't need a connected device. Use Command + Arrow keys to rotate the sim (I think that's the shortcut). Lastly, after figuring out "what's happening" when you rotate (what methods are being fired), you'll need to somehow implement the new methods you mentioned in your post. This the part that will get tricky because you "have no idea what you're doing" (still funny). But...after getting through this post you're already much further along than you were! I'm guessing you'll end up finding something on Google or StackOverflow that may help you get through that part? Dunno. It sounds like some methods need to be setup to "tell" iOS what interfaces you "want" to support...then "ask" iOS when the thing rotates so you can return..."YES", auto rotate the darned thing already like you used to in the good-ole'-days of iOS! I'll look at this post a few times this weekend and see where you gave up. I'm travelling (literally at the airport as I type this) until monday but will try to add something useful if I see your remarks. Who knows, you may have this thing spinning by the time I get back! Good luck!
 
Lester
buzztouch Evangelist
Profile
Posts: 17
Reg: Aug 12, 2011
Florida
10,670
like
09/14/12 03:04 AM (11 years ago)
Of note I'm seeing this in Console: "Application windows are expected to have a root view controller at the end of application launch" The app I'm working this on is 5 tabs with menu list screens on each. Building Universal and just want rotation enabled for iPad. The app is working as intended now when building with Xcode 4.5 on the 5.0 simulator, but stuck on portrait on 6.0. I know it's not a bt issue as so many other folks have the same problem from reading the dev forums. I have some rotation checking in the new shouldAutorotate methods I added to BT_rotatingNavController and BT_rotatingTabBarController but they are never called on 6.0. The best I can figure is that I still need to set the root view controller in the AppDelegate. I'm not sure how to do that other than [window setRootViewController:tabBarController]; and every variation I can imagine, but no luck. I'm going to sleep on it, work on my patience, and reengage tomorrow. Thank you so much for your explanations and safe travels!
 
Lester
buzztouch Evangelist
Profile
Posts: 17
Reg: Aug 12, 2011
Florida
10,670
like
09/14/12 10:47 AM (11 years ago)
Got it working...for tabbed apps, replaced this line in the appDelegate: [self.window addSubview:[self.rootApp.rootTabBarController view]]; with this: [self.window.rootViewController = self.rootApp.rootTabBarController view]; And to get non-tabbed apps, replaced this line: [self.window addSubview:[self.rootApp.rootNavController view]]; with this: [self.window.rootViewController = self.rootApp.rootNavController view]; Also changed the BT_info.plist UISupportedInterfaceOrientations to the appropriate orientation settings I wanted. I'm not finding any immediate issues on the simulator or devices, so I hope this is legit!
 
MrEd
Lost but trying
Profile
Posts: 1
Reg: Sep 20, 2012
Portland, OR
10
like
09/20/12 10:32 AM (11 years ago)
>> "Autorotation is changing in iOS 6. In iOS 6, the shouldAutorotateToInterfaceOrientation: method of UIViewController is deprecated. From what I can tell they were removed! Not deprecated. If they were deprecated that would mean they would still work but would throw compiler warnings that in the future they would be removed. This has been a long agreed practice. Just removing them is so unprofessional. So, all of the sudden a new iOS comes out and things that worked in the previous version just stop working. Come on guys give us a break!!! Good thing we have forums like this to help those of us that are actually programming and don't have time to read all Apple's prerelease documentation. Thanks to you David & Lester!!! Update!!!: After reading my post it hit me that some might think I am being Rude. That is not my intention and I do not want to break the rules of the forum on my first post. I am not meaning for this post to be rude, but frustrated. I don't understand why Apple makes choices like this and I don't know how to get them to get it.
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
09/21/12 08:19 PM (11 years ago)
@Lester: Awesome post, will save us tons of time. I dug around a bit and came to some conclusions that match your findings. Expect a system wide rollout soon when we can get some tests made. @MrEd: No worries, not rude. Sharing your sentiments about Apple (or anyone else for that matter) is totally OK. We agree that this approach is counter to their previous approach where they would deprecate methods and not remove them entirely. My concern, and my testing has been focussed on this, is the idea that "older devices" have no knowledge of these new methods and will continue to rely on the old rotation logic. This makes me wonder how both older, and newer devices can be supported with the same code base. It's important to us that all iOS devices are supported within the same code so app owners don't have to worry about it! Because you're in Portland, kindly comment on the post here: https://www.buzztouch.com/forum/thread.php?tid=D6ED559B999D4DBDA720248 The saga continues....and welcome aboard.
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
09/22/12 03:09 AM (11 years ago)
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.