I've got a really weird problem that I need some help with.
The setup:
I have an iPad app with a UITabBar with multiple tabs. Each tab has one giant UIWebView.
My app adapts to all device orientations. I'm using the ViewWillAppear method to get the orientation before opening a tab, and then making sure all my elements fit well.
All of this works just fine.
The Procedure:
1. We start by opening the app in Portrait mode. The UITabBar automatically selects the first tab. Our UIWebView loads. Perfect.
2. Next we tilt the iPad into landscape mode. Our UIWebView rotates around, and everything looks right, but if I initiate a scroll gesture in the right 1/3rd section of the screen, it doesn't recognize the gesture. The screen is working fine--I can initiate the gesture on the left, and keep scrolling up and down while moving over to the right, and the scroll is still locked in. So the screen is fine.
To boil it down: The gesture recognition on the right 1/3rd portion of the screen doesn't work once the device is rotated into landscape mode.
Here is my code that I use when the device rotates:
Code:
//Detected a rotate into landscape. Move elements appropriately.
mainwebview.frame = CGRectMake(0, 44, 1024, 655);
navbar.frame = CGRectMake(0, 0, 1024, 44);
when you change to landscape, are the dimensions and orientation of the view that the webview exists in correctly
ie
is the view dimension being changed so it resizes to landscape, if not, thats your problem, no objects such as buttons, touch enabled views, and UIWEBVIEWS rect to touches if they are outside the view.
the view defines not only the holding object for all elements, but the constraints to which the objects are interactive
inside view > object is interactive and you can use it
outside view bounds > not interactive
1 way to do this, is set the background color of the view that holds the uiwebview to redColor
set the uiwebview so that it is semi transparent (it wont be interactive, but all you want to do is check the size of the view background)
you will notice that the view is still in portrait mode
this should help, i had this problem also, until i realised that it doesnt AUTO resize everything for you
Quote:
Originally Posted by mriphoneman
Hey all,
I've got a really weird problem that I need some help with.
The setup:
I have an iPad app with a UITabBar with multiple tabs. Each tab has one giant UIWebView.
My app adapts to all device orientations. I'm using the ViewWillAppear method to get the orientation before opening a tab, and then making sure all my elements fit well.
All of this works just fine.
The Procedure:
1. We start by opening the app in Portrait mode. The UITabBar automatically selects the first tab. Our UIWebView loads. Perfect.
2. Next we tilt the iPad into landscape mode. Our UIWebView rotates around, and everything looks right, but if I initiate a scroll gesture in the right 1/3rd section of the screen, it doesn't recognize the gesture. The screen is working fine--I can initiate the gesture on the left, and keep scrolling up and down while moving over to the right, and the scroll is still locked in. So the screen is fine.
To boil it down: The gesture recognition on the right 1/3rd portion of the screen doesn't work once the device is rotated into landscape mode.
Here is my code that I use when the device rotates:
Code:
//Detected a rotate into landscape. Move elements appropriately.
mainwebview.frame = CGRectMake(0, 44, 1024, 655);
navbar.frame = CGRectMake(0, 0, 1024, 44);
where are you detecting the rotation, im thinking that you are doing it in the uiviewController, or, in a parent uiviewcontroller
say for example, the first uiviewcontroller you initialize and add its view to the main window, in there, you detect rotation, call a method, for example
[self.theWebViewController callLandscapeMode];
self.theWebViewController was initialized in the main UIViewController (the one which is added to the window
callLandscapeMode is inside theWebViewController, that method should do the following
-(void)callLandscapeMode
{
CGRect landscapeViewRect = CGRectMake(0,0,1024,768);
[self.view setFrame:landscapeViewRect];
// you can also change the webviews frame in here, keep it all toghether
// so things are not messy
}
generally, what i have found is, any controller that is initialized inside another UIViewController will not respond to rotation calls, the inbuilt methods, so i do it myself.
see if that works
track it with an NSLog
you can also track your current call to change the bounds with NSLog, and i bet it is not getting called.
window
> mainViewController (webviewcontroller is initialized here)
> mainView
>> theWebView (i cant detect rotation)
Quote:
Originally Posted by mriphoneman
Hey,
I made the view red, and it looks like that's the problem.
I've worked out some code, but it's not turning the view.
when you change to landscape, are the dimensions and orientation of the view that the webview exists in correctly
ie
is the view dimension being changed so it resizes to landscape, if not, thats your problem, no objects such as buttons, touch enabled views, and UIWEBVIEWS rect to touches if they are outside the view.
the view defines not only the holding object for all elements, but the constraints to which the objects are interactive
inside view > object is interactive and you can use it
outside view bounds > not interactive
1 way to do this, is set the background color of the view that holds the uiwebview to redColor
set the uiwebview so that it is semi transparent (it wont be interactive, but all you want to do is check the size of the view background)
you will notice that the view is still in portrait mode
this should help, i had this problem also, until i realised that it doesnt AUTO resize everything for you
Hello,
Do you think this is the same problem I'm facing (detailed in this thread: http://www.iphonedevsdk.com/forum/ip...rait-view.html) ?
In the tabbarcontroller I am using, in the willRotate method I remove the view from the superView and add another view instead (landscape view). But once the landscape view has "taken the control" I cannot move back to the protrait view (it seems that the methods are not triggered).
Thanks a lot,
Luc