autoscroll page to top when turning from portrait to landscape - iphone

I've made a site for iphone and all is fine except that I'd like the homepage to auto-scroll to the top when rotated to landscape. I have set the address bar to auto hide via javascript, so when the site loads in portrait the masthead is at absolute top of the page.
Currently what happens is when the device is set to landscape the page viewport shows pretty much the center two quarters of the page with the masthead no longer visible. I would like the page to automatically scroll to the top so the masthead is visible.
Is there a bit of JS to make this possible? or maybe it can be done with UIScrollView - of which i'm new to.
Thanks in advance

Related

full screen zoom pan use UIScrollView in iphone

I have follow a sample code, for create a simple image view zoom/pan page, but it will have the navigationController to back to main page. I have set the navigationBar to alpha to 0.3. But below the navigationBar, I can not see the image content. I have research the reseaon, the frame and bound is 320*480. Also in the xib file, change the "Status Bar" to None. It does not work.
How can I maek the image view full screen like the native photo app. THx.
just provide a new tapguesture which provide user a facility to hide navigation bar and again on tap the bar is shown again

Uiwebview starting in landscape doesn't resize to portrait correctly, but starting in portrait everything works fine

This is a pretty weird error. I have a tab bar controller, with a nested navigation controller, which then has your standard tableview. When you click on a cell a new view is pushed onto the controller. This is a regular view with a nested uiwebview, that takes the entire view up.
When entering that view in portrait mode it looks great, when you rotate it to landscape it looks great, and back to portrait again is good.
But when you enter that view using landscape it looks great but rotating to portrait doesn't seem to resize, the width is still too wide and the text is larger.
I've tried
1.webView.frame = self.view.frame;-That didnt seem to change its behavior
2.Both the view and the webview are set to autosize and like i said it works when starting in portrait
3.[webView setFrame:CGRectMake(0, 0, 320,411)]; when rotating to portrait from landscape. This is really weird, it makes the webview consume half the screen. Font is still large.
4.I've changed the autoresize to disabled, manually resize them on orientation change and then do a [webView reload];
Ive tried various other things and combinations of things. This problem is consistent across all of my subviews that are webviews.
I am sort of new so please be as specific as you can.
Use <meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0;'> in the head of your html

How to show status bar on top of custom camera overlay?

I have this critical issue with showing top statusbar on the custom camera overlay which seems impossible for me at the moment. I posted the same question to Apple dev forum but did not get any response for some time now.
In my application, I have a custom overlay view set as the overlay to the UIImagePickerController. At the bottom of the custom overlay view (this is a UIViewController), I have put a toolbar that enables user to click on toolbar items. Since the top statusbar is not shown when the camera opens up, the whole screen get pushed upwards and makes a narrow white color gap between the bottom of the screen and the bottom tool bar.
I am not aware of how to resolve this issue, but I think if we can show the top status bar on the top of the camera then this will be automatically get resolved. Thanks for any answers.
Had a similar problem a while back and all I did was resize my view. Why not try that and see if it works.
If that doesn't work then showing the status bar should be
[[UIApplication sharedApplication] setStatusBarHidden:NO];
Thanks for the tip domino, I found how it should be done from this thread and resize the main uiview to 320x480 instead of default 320x460. Hope this will help someone else. Thanks.
Can't resize UIView in IB

iphone: reloading webview with rotation

i'm using uiwebview to display a very basic html page with just text. i want to support landscape and portrait orientations but i'm having a problem with resizing when the orientation changes. specifically, when the iphone is rotated to landscape, it zooms in on the text (i want the text size to remain the same and for it to fill the wider horizontal space). when it is rotated back to portrait, the text returns to the correct size but now it flows off the page to the right.
i think the solution is to reload the page with each change in orientation. is there a way to reload the page each time the iphone is rotated?
You can call reload on the web view when the view controller receives either of these methods:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation;
You could try setting scalesPageToFit=NO in the web view. You have fairly fine grained control of the webview from the html. Look at the viewport and other meta tags you can use.

How do I change the scrolling distance of a UIView to be like Safari app

I want to have a UIScrollView that scrolls less then the full screen so that it looks like the Safari app does when you go to make a new tab or look at all the tabs. What property would this be?
When viewing "tabs" in Mobile Safari each tab is a UIWebView placed in a paged UIScrollView. When you "zoom out" to switch between them a CGAffineTransform to reduce the scale of the web view is being applied.