Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 16    Views: 64

basement
Aspiring developer
Profile
Posts: 488
Reg: Apr 07, 2011
Ontario
4,880
06/11/12 02:26 PM (13 years ago)

rotation allowed only on photo page? (iOS)

I'd like to have my app so that only the photo gallery can rotate. Currently, I've set it so that no pages rotate, but is there a way to override that for just the one page? thanks BT 1.5 iOS5
 
MQCMobile
Lost but trying
Profile
Posts: 85
Reg: Feb 13, 2011
Oklahoma
5,950
like
06/11/12 09:27 PM (13 years ago)
I'm trying to figure this out too. I've found a couple of things on Stackoverflow but I haven't tried them out yet: http://stackoverflow.com/questions/4003786/how-to-support-landscape-portrait-orientation-only-for-one-uiview http://stackoverflow.com/questions/356882/how-can-i-display-one-uiview-in-landscape Good luck. I'll let you know if I get it working too.
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
06/12/12 06:56 AM (13 years ago)
right here- follow AESCLEAH tips in this thread and you'll get it. http://www.buzztouch.com/forum/thread.php?tid=AC9F90E72962E3E7595AAAF basically you allow the app to rotate and then you are inserting code on specific screens to disallow them to rotate. it works. i use this concept in all apps now to control the orientation. the only flaw is when you are rotated and go back to a screen that isn't supposed to rotate, it sticks a little there. (code is not smart enought to know to auto rotate back. i bet that could be fixed but i can cope with it the rare times it happens) I wish AESCLEAH would post more, the guy really seems to know code quite well. I learned a ton from some of his other posts. Brilliant and lays out the steps very well.
 
basement
Aspiring developer
Profile
Posts: 488
Reg: Apr 07, 2011
Ontario
4,880
like
06/12/12 09:25 AM (13 years ago)
(oops double posted – please delete)
 
basement
Aspiring developer
Profile
Posts: 488
Reg: Apr 07, 2011
Ontario
4,880
like
06/12/12 09:26 AM (13 years ago)
yikes! I'll have to sit down in the quiet with a cup of tea and go over that really carefully.......I've got many pages on my app though, and this will be a huge pain to do. I wish there were a way to say no rotation to all except one, rather than saying rotation to all and individually saying no rotation to all the ones you don't want to rotate... unless I could just swap the can and can't rotate functions like this: (the original script mentioned in your link above) if([theViewController isKindOfClass:[BT_screen_rssReader class]]){ canRotate = FALSE; }else{ canRotate = TRUE; } (change it to) if([theViewController isKindOfClass:[BT_screen_rssReader class]]){ canRotate = TRUE; }else{ canRotate = FALSE; } I don't know, but I see no reason why that wouldn't work....I'll try it and report back!
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
06/12/12 09:54 AM (13 years ago)
i said the same thing at first, but break it down and go step by step and it makes sense. don't fear it, you can do it! no question the way you suggest is easier but just not how BT was designed. maybe they will make that mod down the road. but that method is worth learning if you want to have some control the orientation now. it was the missing piece, final touch on some apps IMO. you don't have to modify every screen in your app. read his post(s) to understand how it affects all of certain SCREEN TYPES. worst case is modifying maybe 5 files (unless you made some custom plug-in screens!) once you get the code down - you'll be able to re-use it for other apps. really, it's a great piece of code he shared.
 
Cyrus_8888
I hate code!
Profile
Posts: 151
Reg: Dec 24, 2011
Sydney
1,610
like
05/27/13 11:39 PM (12 years ago)
Greeting All, Thanks for your great tips. I couldn't get it to work. My objective is to make image gallery plugins to rotate for landscape & portrait mode. The rest of the screens stay in portrait. So far I have edited my.appDelegate.m, BT_navigationController.m, BT_tabBarController.m, and BT_screen_images.m based your instruction. Xcode console has an output message in below when I rotated my iphone's orientation: my_appDelegate: supportedInterfaceOrientationsForWindow SHOULD NOT ROTATE Self host iOS: 6.0 Any help would be greatly apprecaited, Regards, Cyrus
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
05/28/13 06:40 AM (12 years ago)
I haven't tried it with the image gallery yet - but this technique here is what I'm using now in my apps to control rotation. https://www.buzztouch.com/forum/thread.php?tid=9BFDFCCE41ABBF0A6FD40B7 It's solid - give it a try. The only glitch seem to be the rotation back to a screen that isn't supposed to be rotated. Sometimes the view didunload doesn't fire depending on the plugin screen I'm using. I've seen it go back to an improperly rotated screen. but as soon as you click an action on that screen or refresh it - it snaps back to the proper orientation. IMO Kittsy technique is the closest we'll ever get to controlling rotation per screen. I'm planing to mod some plug-ins to control this via JSON - but it requires you editing the app delegate for each project as well. BT would be wise to look at this technique and implement something similar for everyone.
 
Cyrus_8888
I hate code!
Profile
Posts: 151
Reg: Dec 24, 2011
Sydney
1,610
like
05/28/13 08:20 AM (12 years ago)
Thank you ATRAIN53! But I couldn't figure out how to modify the BT_screen_images.m files which is equivalent to the At53_video_player.m file. Code as in below. I'm using the self host 2.0, the image gallery plugins I was downloaded from buzztouchmods.com Regards, Cyrus At the end of this method -(IBAction)playMovie:(id)sender{ around line 129 add [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"allowMove"]; next find this - (void)movieEndedMethod:(NSNotification*)aNotification{ around line 171 add [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"allowMove"]; That's it the mystery solved You can use this method for other screens just add the lines to view did appear [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"allowMove"]; and to return to normal create this method and put it before the dealloc at the bottom -(void)viewDidDisappear:(BOOL)animated{ [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"allowMove"]; }
 
Cyrus_8888
I hate code!
Profile
Posts: 151
Reg: Dec 24, 2011
Sydney
1,610
like
05/29/13 08:17 AM (12 years ago)
@ ATRAIN53, Any luck? Any help would be nice. Thanks in advance.
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
05/29/13 08:59 AM (12 years ago)
Sorry - I didn't realize you wanted me to look at this.... I don't use the BTM Photo Gallery, I use the Mac one on the plug-in market. But I'm sure the code is pretty similar and this will work the same. You need to edit the appdelegate file first to set-up the NSUserDefaults. This way the screens know what to do with the BOOL you are setting. Kittsys code/explanation in the above post has it listed very nicely. after that edit is done - open the BT_screen_images and drop this right at the top of the viewdidload method: [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"allowMove"]; Then you are adding/creating a new method in the same file at the bottom: -(void)viewDidDisappear:(BOOL)animated{ [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"allowMove"]; } This is what tells the app to stop allowing rotate for THIS screen. It's 3 steps/edits. 1 edit in the app delegate 2 in the bt_scren_image If you want to send me your files I'll try to drop the code in there for you. I need the appdelegate.m file and the .m from the photo gallery code.
 
Cyrus_8888
I hate code!
Profile
Posts: 151
Reg: Dec 24, 2011
Sydney
1,610
like
05/29/13 10:45 AM (12 years ago)
@ATRAIN53, thanks so much for your well explanatory. I have encountered error when I input "[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"allowMove"]; " to the BT_screen_images.m file. Screenshot below https://dl.dropboxusercontent.com/u/20163884/screenrotation/1.jpg
 
Cyrus_8888
I hate code!
Profile
Posts: 151
Reg: Dec 24, 2011
Sydney
1,610
like
05/29/13 10:54 AM (12 years ago)
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
05/29/13 11:39 AM (12 years ago)
You almost had it! You had the right snippets in the right files - we just had to move them around a bit. That first snippet needs to be INSIDE the vdl method. You just had it out the on it's own, not in any method. Try these out and let me know- https://dl.dropboxusercontent.com/u/73858894/BT_screen_images.m https://dl.dropboxusercontent.com/u/73858894/paradisoterrace_appDelegate.m
 
Cyrus_8888
I hate code!
Profile
Posts: 151
Reg: Dec 24, 2011
Sydney
1,610
like
05/29/13 05:52 PM (12 years ago)
BRAVO. Nice work ATRAIN53!! When you press "back" navigation, it seems like all my other screens is in landscape mode. How can I make this to auto rotate in portait?
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
05/30/13 06:55 AM (12 years ago)
Interesting. It's def not a perfect solution yet and really have tested it on a few plug-ins, notably the my video one. I experience some of the same glitchiness with the screen stuck rotated when you return to screens. I think we have the right code here, it's just a matter of fitting it in the right spots. I think there is some BT controller overriding code here I'm looking for....
 
Cyrus_8888
I hate code!
Profile
Posts: 151
Reg: Dec 24, 2011
Sydney
1,610
like
05/30/13 03:17 PM (12 years ago)
@ATRAIN53, I have posted my question on the those threads to Kittsy. Finger cross https://www.buzztouch.com/forum/thread.php?tid=9BFDFCCE41ABBF0A6FD40B7
 

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.