Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
Hi all, I would design a landscape interface based on UIImageViews, that must be setup in interface builder. I haven't found a way to perform the design in IB.
When i rotate clockwise the interface designer(in IB), I can set up all my images the way I like, then I block programatically the orientation to landscape in Xcode. But when emulator starts, images are rotated 90°!!
I mean, let's say I have an image representing a group of up arrows, in landscape mode. I set the Image in a UIImageView control in IB that I just dragged on the main view. When I rotate the interface designer the arrows still remain in the up direction, but when I start the emulator, the phone turn landscape (that's ok) but the arrows are directed to the left!
The only way I found to do this correctly is to rotate the images with a image editing software, and editing the interface in IB as if the phone is in portrait mode, but this seems to me so stupid!
Hi all, I would design a landscape interface based on UIImageViews, that must be setup in interface builder. I haven't found a way to perform the design in IB.
When i rotate clockwise the interface designer(in IB), I can set up all my images the way I like, then I block programatically the orientation to landscape in Xcode. But when emulator starts, images are rotated 90°!!
I mean, let's say I have an image representing a group of up arrows, in landscape mode. I set the Image in a UIImageView control in IB that I just dragged on the main view. When I rotate the interface designer the arrows still remain in the up direction, but when I start the emulator, the phone turn landscape (that's ok) but the arrows are directed to the left!
The only way I found to do this correctly is to rotate the images with a image editing software, and editing the interface in IB as if the phone is in portrait mode, but this seems to me so stupid!
Thanks for helping, I'm stuck :/
Andrew
did you ever get this figured out? i am having the same issue...
did you ever get this figured out? i am having the same issue...
If I remember correctly, I used to rotate all the images using an CGAffineTransformMakeRotation and passing a radians-equivalent of 90 degrees. Actually I don't have any snippet of code, let me tell you if you need it so I can post it.
the main xib displays correctly but the secondary xib called from the first is off by 90 degrees... do i need to add things to the plist for every xib or any way to pass down properties from the main xib to the secondary xibs?
i had this problem i just turned all my images 90 degrees in iphoto it took about 40 seconds to turn 90 images. then i dragged them all out to a folder.. they had the same names i used thoose turned images and kept the vertical view on the xib file but just turned my head sideways and built like that... then in simulator tested it by pressing apple+left ... or in some cases... apple + right
yeah it's kinda hard to use IB when it's rotated.... i'll rotate the image and then when i do landscape it'll flip in semi portrait mode IN landscape so it looks cut off......
well i did some google research and found a guy who said he got it working... but this is all he posted
To get this far, I am setting the "UIInterfaceOrientation" property to "UIInterfaceOrientationLandscapeRigh t" in the .plist file, and I have changed the "shouldAutorotateToInterfaceOrientat ion" methods to return TRUE for only "UIInterfaceOrientationLandscapeRigh t". Also, I added these lines: [application setStatusBarOrientation: UIInterfaceOrientationLandscapeRigh t animated:NO]; [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRigh t];
to the applicationDidFinishLaunching method.
i dont know what it means cause im a noob maybe u can make some scence of it
i might be super retarded. on the "MainWindow.xib" do i need to link the two secondary views in the connnections tab to the app delegate or to the secondary views?
I'm dealing with the exact same problem. I've setup the extra view controllers correctly with TRUE, did the info.plist, rotated all the views in IB and still have this problem. I'll let you guys know if I figure it out.
PegLight - Create peg style art on your iPhone. <img src="http://www.iphonedevsdk.com/forum/images/smilies/biggrin.gif" border=
Okay here is a work around. I call it a work around because I really think this problem is a bug and should be fixed by apple. This workaround from another thread so I cant take the credit.
Foreach view controller, do the following:
Add this to the top of your code file:
#define degreesToRadians(x) (M_PI * x / 180.0)
- (void)viewWillAppear:(BOOL)animated {
// First rotate the screen: [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight; // Then rotate the view and re-align it: CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation( degreesToRadians(90) ); landscapeTransform = CGAffineTransformTranslate( landscapeTransform, +90.0, +90.0 ); [self.view setTransform:landscapeTransform];
}
PegLight - Create peg style art on your iPhone. <img src="http://www.iphonedevsdk.com/forum/images/smilies/biggrin.gif" border=
Thanks for all the help with this everyone. I found Knertfield's solution great except that I had problems with buttons. I couldn't click any buttons on the part of the screen close to the Home button - any touch with x-coordinate > 320 was ignored.
If you make your view have a background, you can see what's going on. Go into Interface Builder, click on your view and in View Attributes, set it to have a background color. You'll notice that the view background is *also* rotated when we set the transform in viewWillAppear. So the background only covers part of the screen. Any buttons that are not on the background do not react when you test the app.
To fix this, add the following line of code in viewWillAppear, before you set the status bar orientation.
After 3 hours, I Hate the SDK not user friendly, i found the answer. It was in it all along. Find this code in your existing files, it is commented out by default. Basically uncomment it, and replace "Portrate" with "Landscapeleft" and there you have it. Cheers.
// Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); }
essetesse is utterly correct -- this is the answer to the 64 billion dollar bonus question.
Getting landscape to work is a catastrophe, as of March 2010 (pad era). There are multiple problems.
You see posts about affine transforms but that doesn't apply any more. You see posts about the undocumented routine but that doesn't apply anymore.
You need to use the new property in plist to set the initial orientation,
and you need to use shouldAutorotateToInterfaceOrientation properly everywhere,
and you need to just turn the views (all of them) sideways in IB (use the little arrow at the top right of a 'view' contruction window)
However if you are trying to swap between one view and another (landscape all the time) you face the horror of the "only works first time" problem and you have to set up a master UIViewController, that does nothing except hold all the others.
Finally you have the horrific problem that essetesse has given the solution too, you will see the frames are all messed up.
(Buttons near the right of your landscape screen mysteriously won't work at all...nothing works.)
Just as essetesse says set different bg colors on all your views involved in the mighty view pyramid to see the horrors you are facing.
This indeed is the secret solution .. self.view.frame = CGRectMake(0.0, 0.0, 480.0, 320.0);
Personally I disagree about putting it in ViewWillAppear,
I think you should put it in ViewDidLoad, and/or in shouldAutorotateToInterfaceOrientation:,
alternately set up a timer and have it fire off 100 times a second for every view you have :-O
I don't understand what is going on? Why can't use just click the arrow in the top right corner of interface builder?
I explained it at length in the previous post.
The previous post is the total, exact, answer and indeed is the only way to absolutely correctly do an "all landscape, all the time" app!!!!
The "secret" being the line where you set the frame, where you "force it" or "remind it" about the frame orientation, if you want to look at it that way. self.view.frame = ...
(By the way. Don't forget that, if you are swapping in and out more than one UIView.... You just CANNOT do that unless you have a "wrapper" UIView at the top. So, create a new app with a UIView (or controller) called "holdEverythingInHere". Then if you want two, three or whatever different UIViews, create those. Set the main window's view to be holdEverythingInHere, and forget about it. From then on, set the view of holdEverythingInHere to be whatever one of your views you want at the time. You cannot just change the view of the main window. Have a "holder" view first that just sits there and remains the view of the main window. Then attach your various views to that holder view. AND DONT FORGET, all the way down you have to always apply the "secret trick" above, in holdEverythingInHere and all the "actual" views you are constructing. This is the one and only way to make it work.)
Replies
did you ever get this figured out? i am having the same issue...
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeJust taking a wild guess.. let us know the results
iOS Blog : http://iphone2020.wordpress.com
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeThen in my view controller .m I put:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeLeft];
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
Then in my Info.plist file add a line and put UIInterfaceOrientation with the value UIInterfaceOrientationLandscapeLeft.
The above obviously rotates to LandscapeLeft. You could change this to LandscapeRight!
Hope that helps. Works every time for me!
Ben
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeAndrea Maschio
http://www.2manyclicks.com
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomethe main xib displays correctly but the secondary xib called from the first is off by 90 degrees... do i need to add things to the plist for every xib or any way to pass down properties from the main xib to the secondary xibs?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeSay they are called MyViewController, then MainView and SettingsView.
In the MyViewController.m I have:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeLeft];
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
This first call also tells the statusBar to rotate as well.
In the other two views .m files I have:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
Then in my Info.plist I have "UIInterfaceOrientation" with the value "UIInterfaceOrientationLandscapeLeft".
This works well for me.
Check you don't have something similar already in your code that maybe clashing/re-setting the orientation!
EDIT: Make sure the second bit of code is in every viewController inc your RootViewController.m
Ben
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomedo i need to link the "view" in IB back to the main View as the file's owner?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomei used thoose turned images and kept the vertical view on the xib file but just turned my head sideways and built like that... then in simulator tested it by pressing apple+left ... or in some cases... apple + right
search for me in the app store.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeTo get this far, I am setting the "UIInterfaceOrientation" property to "UIInterfaceOrientationLandscapeRigh t" in the .plist file, and I have changed the "shouldAutorotateToInterfaceOrientat ion" methods to return TRUE for only "UIInterfaceOrientationLandscapeRigh t". Also, I added these lines:
[application setStatusBarOrientation: UIInterfaceOrientationLandscapeRigh t animated:NO];
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRigh t];
to the applicationDidFinishLaunching method.
i dont know what it means cause im a noob maybe u can make some scence of it
search for me in the app store.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI used a flipView app as a start.
I found that if it was for SDK 2.0 it didn't work.
But for SDK 2.1 and up it did.
What SDK version are you using?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI am not sure what is going wrong for you here...
Anyone else have any ideas?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeForeach view controller, do the following:
Add this to the top of your code file:
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeIf you make your view have a background, you can see what's going on. Go into Interface Builder, click on your view and in View Attributes, set it to have a background color. You'll notice that the view background is *also* rotated when we set the transform in viewWillAppear. So the background only covers part of the screen. Any buttons that are not on the background do not react when you test the app.
To fix this, add the following line of code in viewWillAppear, before you set the status bar orientation.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeIt was in it all along. Find this code in your existing files, it is commented out by default.
Basically uncomment it, and replace "Portrate" with "Landscapeleft" and there you have it.
Cheers.
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeGetting landscape to work is a catastrophe, as of March 2010 (pad era). There are multiple problems.
You see posts about affine transforms but that doesn't apply any more. You see posts about the undocumented routine but that doesn't apply anymore.
You need to use the new property in plist to set the initial orientation,
and you need to use shouldAutorotateToInterfaceOrientation properly everywhere,
and you need to just turn the views (all of them) sideways in IB (use the little arrow at the top right of a 'view' contruction window)
However if you are trying to swap between one view and another (landscape all the time) you face the horror of the "only works first time" problem and you have to set up a master UIViewController, that does nothing except hold all the others.
Finally you have the horrific problem that essetesse has given the solution too, you will see the frames are all messed up.
(Buttons near the right of your landscape screen mysteriously won't work at all...nothing works.)
Just as essetesse says set different bg colors on all your views involved in the mighty view pyramid to see the horrors you are facing.
This indeed is the secret solution ..
self.view.frame = CGRectMake(0.0, 0.0, 480.0, 320.0);
Personally I disagree about putting it in ViewWillAppear,
I think you should put it in ViewDidLoad, and/or in shouldAutorotateToInterfaceOrientation:,
alternately set up a timer and have it fire off 100 times a second for every view you have :-O
Frustrating stuff !
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeThe previous post is the total, exact, answer and indeed is the only way to absolutely correctly do an "all landscape, all the time" app!!!!
The "secret" being the line where you set the frame, where you "force it" or "remind it" about the frame orientation, if you want to look at it that way.
self.view.frame = ...
(By the way. Don't forget that, if you are swapping in and out more than one UIView.... You just CANNOT do that unless you have a "wrapper" UIView at the top. So, create a new app with a UIView (or controller) called "holdEverythingInHere". Then if you want two, three or whatever different UIViews, create those. Set the main window's view to be holdEverythingInHere, and forget about it. From then on, set the view of holdEverythingInHere to be whatever one of your views you want at the time. You cannot just change the view of the main window. Have a "holder" view first that just sits there and remains the view of the main window. Then attach your various views to that holder view. AND DONT FORGET, all the way down you have to always apply the "secret trick" above, in holdEverythingInHere and all the "actual" views you are constructing. This is the one and only way to make it work.)
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomeset the info.plist as decribed in the many posts above.
and add the following method. what this does is return a "NO" to the call any time the ipad/iphone goes into portrait and a "YES" any time it goes into landscape.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome