I am developing an application that read pdf in landscape mode. I write the following code and its works fine. But my problem is I download pdf reder code from
https://github.com/brow/leaves and implement that code in my application, after that in project my LandScapeViewController's base class is LeavesViewController (if I use the baseclass is UIViewController then it is working fine). So when i push from viewController to LandScapeViewController it works properly. But at that time i rotate the view more then two times or in 360 degree then i go to back. Its not working properly. Means after landscapeviewcontroller it must transfer portraitView but it can't do this. I give my project. Please Help me.
I search lots of in SO but all solution is base class is UIViewController but i need the LeavesViewController
Before rotation My first view is
then click on Button and rotate the view in 360 degree, After rotation click on back button and it display view like
This is the my code == MyCode
I write that code from heare set Portrait Mode to Landscape
Related
I was given a project that was started by someone else who no longer works here.
I have a UITabBarController which holds some UIViewControllers.
If the application is running on iOS 6, everything runs fine, However as soon as I run it on iOS 5, all UIViews are rotated 90 degrees and given an origin value of something around -100 to -300
I have been able to loop through all view controllers of the tabBar and set
myView.transform = CGAffineTransformMakeRotation(0.0);
myView setFrame:CGRectMake(0,0,1024,748);
The initial view controllers on UITabBarController appear correctly, However, if I ever try to launch a modal view controller, everything is stuffed again. including the modal.
I am running out of ideas on how I could fix this once and for all. I couldn't find anything in the code that rotates the views.
What I could deduce is
on iOS 6, the first subview of the main view holding the UITabBarController is UILayoutContainerView
but on iOS 5 the first subview is of class UIView
If this is an issue with UILayoutContainerView not being supported in iOS5, how can I make the application backwards compatible now?
Note: we only support Landscape (Right/Left) and only on iPad.
Also, I have noticed that if the user rotates the application before initialiazing the UITabBarController and its sub controllers. everything works fine. Even if you re-run the application and not rotate again, still works.
Thanks in advance
If you want your application to stick in landscape mode you the blow code, the issue resides in iOS 5, many people face this issue
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
BOOL returningValue=NO;
if (interfaceOrientation==UIInterfaceOrientationIsPortrait(interfaceOrientation))
{
returningValue=NO;
}
else if(UIInterfaceOrientationIsLandscape(interfaceOrientation))
{
returningValue=YES;
}
return returningValue;
}
Apparently, this is where I went wrong
For iOS 5
when setting the view of the main window of the application, one must use
[self.window addSubview: tabBarController.view];
Instead of (iOS6 only)
[self.window setRootViewController: tabBarController];
I am unsure how that changes everything, and the reason it won't work for iOS 5. Nevertheless, it worked.
Thanks everyone :)
When I'm making another window the key window the status bar does not rotate according to what the current key window's root view controller responds to should autorotate.
I created a sample project that clearly demonstrates what I'm talking about:
http://bit.ly/tFLodd
Just run the app in the simulator rotate the interface and press the switch button rotate rotate ... and switch ... etc.
Does anybody have any ideas how to fix this?
Thanks
I'm having trouble getting my app to rotate since switching to Xcode 4 and iOS 5. After tearing my hair out, I created a brand-new test project to see if I could get a bare-bones app to rotate.
I created the test project using the 'Empty Application' template. All I added to this template was a UINavigationController, with a UIViewController pushed onto it. There is a nib file for the UIViewController, with one label that says 'Hello'.
On the target Summary screen, I clicked in all the buttons for 'Supported Device Orientations'.
In the .m files for the Navigation and View controller code I changed shouldAutoRotate... to:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (YES);
}
The test project builds with no issues and runs perfectly. There's a navigation bar and friendly 'Hello' message, but the darn thing won't rotate!
Obviously, I am missing something pretty simple, but I can't figure out what it is. My suspicion has fallen on the .nib. Under 'Simulated Metrics', there is an attribute called Orientation. This is set to Portrait. The only other choice is 'Landscape'. If I change this setting to 'Landscape' the view in the .nib editor changes to landscape, but when I run the app, it runs in Portrait mode, and still refuses to rotate.
Hopefully, someone will get a big laugh out of my blunder and point out the goofy mistake I'm making. Please do!
in your RootViewController.m find the line
return (UIInterfaceOrientationIsPortrait( interface Orientation ) );
and you can replace this with whatever... like
return (UIInterfaceOrientationIsLandscape( interface Orientation ) );
I started out with the UISplitViewController template in Xcode 4, and added a UIImageView that covers the whole detailViewController.
When i run the project the image and views render correctly. If i rotate the device it also renders correct, but if i hit the PopoverButton while in portrait and then rotate the device the image is rendered above the rootView..
I've been trying to reproduce the bug you're experiencing, but without success. Could you provide information about how you add the image view and how you set its frame?
One possible solution that I can think of is setting:
self.view.clipsToBounds = YES;
in viewDidLoad of the detail view controller.
It would however be great if you could provide some code, so that I can reproduce the bug and tell you what's wrong.
I'm pretty new to MonoTouch and I'm having problems getting my app to rotate from portrait to landscape mode.
My project has two XIB files, the MainWindow added by MonoTouch and MainController.xib which I have added. The MainController has a single label and no other controls. In my Main.cs I have the following to load the MainController.xib file:
UIViewController controller = new MainController();
window.AddSubview(controller.View);
In the MainController code I added
public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
{
return false;
}
It all runs fine and the label displays but when I rotate the simulator nothing rotates. I'm sure it's something really simple that I'm getting wrong but I just can't seem to crack it.
Any help would be appreciated.
You can look at TweetStation for a sample.
In this particular case, you might want to return "true" instead of false in the sample above.