So i have a UIWebView that is meant to only scroll horizontally, and its in a UIScrollView that is only meant to scroll vertically. I have almost managed to achieve this, but i have a slight problem.
The UIWebiew's scroll content height is set to the height of the webviews frame, so that it wont scroll vertically, but even when this is the case, it still seems to consume the vertical scrolling event (sometimes), since i can see the side scroll bar show, but it wont scroll (and doesnt scroll the scrollview that the webview is contained in).
It needs to be like this because there are some elements that need to scroll vertically with the webview, but not horizontally (think of the safari app how the addressbar scrolls with the webview)
does anyone know how i would pass the vertical scroll event through but keep the horizontal scroll event for the UIWebView?
i had a look at this answer but its not quite what im looking for
update:
so typically just after i ask the question i find a suitable answer on another question... (had been searching for a few hours now) this answer should do the trick for me, ill give it a go and report back
Just set
scrollView.alwaysBounceVertical = NO;
scrollView.contentSize = CGSizeMake(
scrollView.frame.size.width, scrollView.contentSize.height);
scrollView.showsVerticalScrollIndicator = NO;
Edit:
doesn't seems to work. Too bad..
Try implementing
- (BOOL)gestureRecognizer:(UIGestureRecognizer*)gst
shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer*)gst2 {
return YES;
}
..in your view containing the scrollView and webView, or even the scrollView itself (containing the webView).
So the solution i found that i posted in the question works for the most part, it does exactly what i need, but for some reason after a webpage loads, it scrolls the headerbar away showing just the webpage, which isnt the end of the world but its not pretty. it seems the event fires after the webViewDidFinishLoad: so i cant just reposition it back to the top. Ill keep tinkering around, maybe i can find out why its doing it.
Related
I have implemented a horizontal UIScrollview (adding buttons into it) but it always bounces back to original position after I scroll it. Searched a lot but the answers were of no luck as yet.
This is the scroll view below, of the same width as screen,
And this is the view inside it, which is of 800+ width,
Also in me class, I have implemented the following code:
_imageEffectsScrollView.contentSize = CGSizeMake(832, 80);
In fact it just now scrolls a little bit, instead of bouncing back ( like before ):
Please help, how can I make it scroll properly. Thanks!
I have a dilemma that I cant get my head around to why it act as it does. I have some images that describes the problem. I have a sb:
note! the Image view and the mapview are on top of eachother. Toggling hidden or not depending if I have coords or not to display on map.
I add some dynamic text programmatically under the Sb UIView (and set some constraints. so it looks like this in the end:
Problem now is that if i scroll down a bit so that it looks like this:
Then if I hit the mapbutton to go to nextview that containts a bigger mapview and then return to this view. The scrollview is stuck with parts of the map under the navbar. I can ofc force a scrolldown and see the rest of the mapview but when I release it bounces back and party hides under the navbar once again.
I dont understand shit. And tell me if you want me to try to explain this better its 1.30am and my eyes can barely stay open. But still - any help or pointers are valuable to me.
/Pedro
You can scroll to the top of a UIScrollView using [scrollView setContentOffset:CGPointMake(0,0) animated:NO];.
Hopefully i can explain this clearly. I have a UIWebView and I've added a UIToolbar to it's scrollView (another works [webView.scrollView addSubview:myToolbar];). So everything is fine and dandy until i try to pinch zoom that's when the toolbar stays in the corner of the screen, so basically it doesn't stay in the middle. If you haven't guessed already, I'm trying to make a duplicate of safari's behavior. I need to have the UIToolbar to not be affected by the pinch gesture. Any ideas on how to do this? I've read other posts but it doesn't seem to really give an answer. Any help is appreciated :)
You have to create a parent UIView, say rootV, in which you embed myToolbar at the top, and then webView.
This stops the pinching from affecting myToolbar, however this make it stick at the top, and not move beyond the screen when the user scrolls vertically myWebView.
To get the same behavior as Safari, you have to check the vertical scrolling in myWebView, and based on it you expand up or down the size of rootV. Assuming you fixed the height of myToolbar but made webView fill the rest, it should just work.
I have an editable UIWebView into an UIScrollView.
I disabled the scrollview and the bounces on the UIWebView to only rely on the UIScrollView' scrollview.
Each 0.1 second, I have a Timer which detects if the UIWebView content has changed since last check. If so, and if the caret is greater than a given position, the offset fo the scrollView is updated, and the result is pretty good.
My issue is when I go back to edit an already written text.
The UIWebView scrolls on its own view, and the text disappears.
I'd like to use the UIScrollView instead.
Here are two pictures showing the issue:
EDIT: Here is a video showing the bug: http://dl.dropbox.com/u/9666723/Bug.mov
Thanks for any piece of help.
EDIT: The crux of this problem is that scroll indicators do not show during programmatic scrolling, but I would like them to. My original question (provided below) assumed this had something to do with userInteractionEnabled, but it does not. The mention of a master and slave UIScrollView is also possibly distracting from my core problem (the need to show scroll indicators during a programmatic scroll). Apologies to those of you who answered or commented based on my misleading assumptions/info.
Possible Solution: The only way I found to do this was to use the fact that scroll indicators are instances of UIImageView and use a category on it to hack the alpha. This article shows the approach. It was then a case of using tags and scroll view delegate methods to turn the alpha permanently on prior to a programmatic scroll, and permanently off when the scroll is finished. This feels hacky though, so any further suggestions would be welcome!
Everything below this line is the original unedited question to provide context to users' answers and comments
Setting userInteractionEnabled in a UIScrollView object to NO appears to disable the scroll indicators upon programmatic scrolling. This happens even if you have self.showsVerticalScrollIndicator = self.showsHorizontalScrollIndicator = YES;
Is there any way to programmatically scroll the scroll view but still show the indicators?
(To provide some context: I have a slave scrollview that mimics a master scrollview by hooking up the scrollview delegate callbacks and passing the content offset to the slave scrollview. However, I don't want the user to be able to directly manipulate the slave scrollview, but I do want scroll indicators).
Instead of setting userInteractionEnabled to false try setting the UIScrollView's scrollEnabled property to false. The doc. says "When scrolling is disabled, the scroll view does not accept touch events" that should mean that you should still be able to programmatically scroll the UIScrollView. Hope this helps - Did not test it out let me know.
You could try putting a transparent UIView (alpha == 0.0) over your scroll view (but as a sibling in the view hierarchy, not as a subview). Set touchesEnabled to YES on the transparent view, and it will intercept touches heading for the scroll view.