10-21-2010, 10:43 PM
#26 (permalink )
Registered Member
Join Date: Jan 2010
Location: Beech Mountain, NC
Posts: 3
Huzzah!
Quote:
Originally Posted by
kornienkos
[[[bioWebView subviews] lastObject] setScrollEnabled:NO];
works for me
One line is all it took for me. I put it in my viewDidLoad in my ViewController class. I tried the javascript but it only worked on certain pages. also, any page with embedded div content or iframes or dynamic javascript was preventing the javascript fix from working.
[[[myWebLabel subviews] lastObject] setScrollEnabled:NO];
11-18-2010, 09:05 AM
#27 (permalink )
Registered Member
Join Date: Nov 2010
Posts: 2
Stop scrolling in UIWebView
Hi everyone,
read this thread, because I had the same problems with the UIWebView.
Since some approaches posted here did not work out for me, I took another (closer) look at the API.
YES, UIWebView does not inherit from UIScrollView.
BUT! It does conform to the UIScrollViewDelegate
Which means, you can inherit UIWebView and override
- (void)scrollViewWillBeginDragging: (UIScrollView *)scrollView
in this way:
Code:
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
scrollView.scrollEnabled = NO;
}
That's it. No "subviews last index" and so on...
Worked pretty fine for me and I doubt that it will be rejected by Apple.
Rock on!
TH
12-28-2010, 03:00 PM
#28 (permalink )
Registered Member
Join Date: Dec 2010
Posts: 2
Hey,
anybody try
Code:
[(UIScrollView *) [webView6.subviews objectAtIndex:0] setAlwaysBounceVertical:NO];
worked for me
01-03-2011, 06:40 AM
#29 (permalink )
Mobile Application Dev.
Join Date: Oct 2008
Location: Bangalore, india
Posts: 362
Quote:
Originally Posted by
S21Mi
Hey,
anybody try
Code:
[(UIScrollView *) [webView6.subviews objectAtIndex:0] setAlwaysBounceVertical:NO];
worked for me
Worked great.
Seems UIScrollView is first subview of UIWebView.
oooooooops !!!!!!! :-) krashing on below iPhone 4.1 OS.. any other way
Last edited by mpramodjain; 01-04-2011 at 03:28 AM .
Reason: Crashing in below 4.1
01-13-2011, 10:45 AM
#30 (permalink )
Registered Member
Join Date: Nov 2010
Posts: 2
Implementing the delegate Method worked in 95% for me,
since the WebView did scroll some pixels and did top then...
here is my updated solution:
Code:
- (id) initWithFrame:(CGRect)frame{
if (self = [super initWithFrame:frame]) {
for (unsigned i = 0; i < [[self subviews] count]; i++) {
if ([[[self subviews] objectAtIndex:i] class] == [UIScrollView class]) {
UIScrollView *scrollView = (UIScrollView*) [[self subviews] objectAtIndex:i];
[scrollView setScrollEnabled:NO];
}
}
}
return self;
}
Subclassing WebView and then loop through all subViews, if it is a ScrollView, disable it. So I don't mind on which position of the subview array the scrollView is.
01-13-2011, 10:47 AM
#31 (permalink )
Nuisance Developer
Join Date: Jul 2009
Location: Italy
Posts: 4,691
ahahaha cool way to do it.
__________________
01-18-2011, 04:40 AM
#32 (permalink )
Mobile Application Dev.
Join Date: Oct 2008
Location: Bangalore, india
Posts: 362
Quote:
Originally Posted by
dany88
ahahaha cool way to do it.
does it work on all Iphone OS . I mean from 3.0 to the latest iOS versions.
04-27-2011, 08:17 AM
#33 (permalink )
Registered Member
Join Date: Apr 2011
Posts: 1
Thanks
Nice One its Working...
05-23-2011, 07:41 PM
#34 (permalink )
Registered Member
Join Date: May 2011
Posts: 1
Why do all these sub classing and hacks? Put this function in your interface and call it:
Code:
-(void)disableScrollingOnWebView:(UIWebView*)webView
{
for(id sub in [webView subviews]
{
if([sub isKindOfClass:[UIScrollView class]]
{
[sub setScrollEnabled:NO];
}
}
}
i.e.
Code:
[self disableScrollingOnWebView:myWebView];
- Farhad
05-24-2011, 02:22 AM
#35 (permalink )
Nuisance Developer
Join Date: Jul 2009
Location: Italy
Posts: 4,691
that is the same thing posted by TieAetsch....
yes, he used it in init, but the idea was the same
__________________
07-01-2011, 02:33 PM
#36 (permalink )
Registered Member
Join Date: Jul 2011
Posts: 1
This javascript works
Quote:
Originally Posted by
MrMidi
Greetings,
Code:
document.onload = function(){
document.ontouchmove = function(e){ e.preventDefault(); }
};
Enjoy,
- Peter Schmalfeldt
Thanks, the javascript does indeed work and prevents scrolling up/down completely. Unfortunately for the work I'm doing, I do need it to scroll but not bounce (or show the grey-ish top/bottom bounce indicator bars). I'll need to find a different solution than the javascript.
07-01-2011, 02:51 PM
#37 (permalink )
Nuisance Developer
Join Date: Jul 2009
Location: Italy
Posts: 4,691
Quote:
Originally Posted by
pbamma
Thanks, the javascript does indeed work and prevents scrolling up/down completely. Unfortunately for the work I'm doing, I do need it to scroll but not bounce (or show the grey-ish top/bottom bounce indicator bars). I'll need to find a different solution than the javascript.
Code:
-(void)disableBouncesOnWebView:(UIWebView*)webView
{
for(id sub in [webView subviews])
{
if([sub isKindOfClass:[UIScrollView class]])
{
UIScrollView *scrollView = (UIScrollView*)sub;
[scrollView setBounces:NO];
}
}
}
__________________
Last edited by dany_dev; 12-14-2011 at 04:25 AM .
08-27-2011, 06:37 PM
#38 (permalink )
Registered Member
Join Date: Aug 2011
Posts: 1
I Prefer the Simple Answer
You could get really crazy and do this,
[webView setUserInteractionEnabled:NO];
08-28-2011, 03:22 AM
#39 (permalink )
Nuisance Developer
Join Date: Jul 2009
Location: Italy
Posts: 4,691
Quote:
Originally Posted by
ColinX
You could get really crazy and do this,
[webView setUserInteractionEnabled:NO];
that is not what we want to achieve....
__________________
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 385
11 members and 374 guests
chiataytuday , chits12345 , ChrisYates , fiftysixty , fredidf , gmarro , KennyChong , Leslie80 , Meoz , ryantcb , Yosh_K
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,670
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Yosh_K