Resize webview iphone 5 - ios

i'm seeking a method to resize my webview according the current iPhone.
I tried to change the frame of the webview, to check the autolayout etc. but it's not running, I tried other solutions, and i didn't succeed to resize my webview.
I tried for example this but nothing change :
_contenuNews.frame = self.view.frame;
I don't want to use
Scale page to fit.
I want my webview take all the screen.
Someone to help me ? Thx

If your webview is added via IB and if you are using autolayout then you can not resize the frame. For this you need to uncheck the autolayout option from IB.
After that try to resize the frame of your WebView.
Though you didn't want to use scale to fit but it will be good to use scale to fit. It may help other so I am adding it to my answer:
self.webView.scalesPageToFit =YES;
The above code will make sure that the content of UIWebView is loaded inside the view frame.
Hope this helps.. :)

Related

iOS: Button menu with autolayout

I came across the project: https://github.com/monoqlo/ExpandingMenu
which adds a button to a view. when the button is added a menu appears. You can find details behind the link.
The problem is that this project doesn't support autolayout and all frames are hard coded. So it doesn't support device orientation changes.
Currently I'm trying to rebuild it with autolayout. How would you do it?
Start with a xib?
Doing everything hard coded?
Do you know some code that could be reused?
Maybe you can try these:
First: check out the code of ExpandingMenu, I know it hard code, that is to say, it use the frame of its superview or [UIScreen mainScreen]'s frame. Make clear when it set its subviews frame.
Second: first may have 2 options
one is setting its subviews frame when it init or added in view: In this case , you have to rewrite it or else, in a word , you can not use it to support device orientation.
one is setting its subviews frame when it calls layoutSubviews: In this case ,it is able to support device orientation.
That is to say: if it does not support device orientation, you can fix it by rewrite it to make it setting in layoutSubviews.

UIWebView not scaling to UICollectionViewCell

I'm trying to implement a UICollectionView that contains UIWebviews in each cell. I've almost got it working but I am having this problem of not being able to resize the webviews to the cell's content size. Each webview size so far is 1024x704 (width x height) and is a html file. I have enabled scalesPageToFit to YES but all it's doing right now is resizing it to only fit in the upper left corner.
I've checked the frame size of the webview and the collectionviewcell size and i get 1024x704 programmatically even though what is actually appearing seems to be a lot smaller than that.
Any suggestions/help on why this is happening and what I can do to scale it correctly? If I need to supply more info let me know. Thanks
EDIT:
As shown below this is how the UICollectionView looks like on an iPad. The rectangle in the left is the UIWebView and I'm trying to scale it to fit the whole screen.
EDIT2: Just realized I screwed up on how I wrote my html file. Sorry about that guys! Problem solved itself.
Try this:
self.webView=[[UIWebView alloc]initWithFrame:self.bounds];
self.webView.contentMode=UIViewContentModeScaleAspectFit;
self.webView.scalesPageToFit=YES;
self.webView.autoresizingMask=(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);

PDF in UIWebView: Initial view to fill view

I have a UIWebView that displays a PDF. By default it opens the PDF and scales it to fit the entire width in the view, but not the height. I want it to fill the view so that the height stretches down to the bottom.
I have tried using contentModeScaleToFill, zoomToRect, and any other thing that sounded like it might have any relevance.
Can anybody help with this?
You might want to try #Jeff's suggestion and use CGAffineTransformScale to rescale your pdf after it is loaded to fill the screen. Look at his answer here: https://stackoverflow.com/a/3600665/188675
And to answer your question, 1) contentModeScaleToFill is a UIView Constant so it won't help with anything in your case, because you're using a UIWebView. 2) Using CFAffineTransformScale is much more simple and straightforward than using zoomToRect because you don't have to mess with the scrollView.

Why does the UIScrollView could not be scrolled in the iOS simulator?

I'm trying to get familiar with the UIScrollView. I try to set the UIScrollView's contentSizeto full width of the screen and ten times the height of the screen in the corresponding ViewController's viewDidLoad method. However, when I tried to run it on the iOS simulator, I found that the view can't be scrolled. Please kindly help to give some hints & opinion.
Thanks!
You need To check in your Code See
1)Check whether the UserInteraction enabled For The UIScrollView if not Please Do as
[theScrollView setUserInteractionEnabled:YES];
EDIT
2)Please Make Sure You have Enabled The Scrolling of UIScrollView
theScrollView.scrollEnabled = YES;
Thanks.

UIScrollView not working

I have a UIScrollView with a View inside of it. Inside of that view is a bunch of buttons, labels, etc that fit in the View when in Portrait mode...When the iPad is rotated, I want the scrollView to kick in so the user can scroll to the bottom of the view. The app runs, but when I rotate it, the scroller never works...I believe I've wired everything up correctly and I have this code in the viewDidLoad event:
[scrollview addSubview: masterView];
scrollView.contentSize = [masterView sizeThatFits:CGSizeZero];
Is there something else I am missing? Do I need to modify the size when the iPad rotates?
thanks
There may be a problem with the content size of the UIScrollView. Without the contentSize being set larger than the actual scrollView size, scroll bars won't be shown.
You can code this in with something like this:
[scrollView setContentSize:CGSizeMake(2000,2000)];
And then changing the content size to the actual content size of what you are putting in the UIScrollView (scrollView).
If you look at the results of [masterView sizeThatFits:CGSizeZero] (e.g. NSLog or set a breakpoint in your debugger, I think you will find that it's not what you expected it to be. You might find that masterView has autoResize parameters set (which is common for a view that covers the entire screen), which means that it might, itself, be getting resized too short to fit all of its controls and scrollView is simply grabbing this shortened value itself. Take a look at that CGSize and the problem will be obvious.
I faced similar situation but my case was iPhone.
Remember that content should be larger than scroll for scrollView to kick in.
"Why would you want to go down if everything is visible in front of you ?"
use the following code:
[scrollView setContentSize:CGSizeMake(intValue, intValue)];
intValue: Integer values setting width and height of scroll.
Even if it doesn't works, don't worry there are loads of other options to figure out the solution:
1. NSLog
2. Breakpoints
3. Put up errors you are getting from console on stackoverflow

Resources