Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-30-2008, 06:18 PM   #1 (permalink)
New Member
 
Join Date: Oct 2008
Posts: 6
funkaster is on a distinguished road
Default UIWebView inside a ScrollView

I have a UIWebView inside a TableView. Essentially, the TableView is just one cell with some controllers inside. Everything works just fine, except that the webview does not receive the scroll events... is there a workaround for this?
Or should I just take the easy path and place the webview outside the tableview? (something like a footer)

thanks for any tip.
r.-
funkaster is offline   Reply With Quote
Old 10-31-2008, 01:12 PM   #2 (permalink)
New Member
 
Join Date: Apr 2008
Posts: 420
jeff_lamarche is an unknown quantity at this point
Send a message via AIM to jeff_lamarche Send a message via Yahoo to jeff_lamarche
Default

Oh, you've put yourself into a world of hurt. Both of these are subclasses of UIScrollView, and UIScrollView intercepts events - it disrupts the responder chain in a way that really doesn't play nicely with others. If the event turns into a pan or zoom or another gesture the scroll view (or table view, web view, etc) responds to, then that event gets consumed and not passed onto the responder chain.

You could try creating a subclass of UITableView where you override all the event-handling methods, having them all call super and then manually pass the event on to the next responder, but I would be concerned about the law of unanticipated consequences, such as having controls unintentionally triggered when zooming or panning. Perhaps you could manually pass the even ONLY on to the web view, but that would be very kludgey and prone to breaking and would require controller code embedded in a view, which is just ugly in a .NET kind of way.
__________________
Check out my iPhone Dev Blog
You can send me e-mail at my forum username at mac dot com.
jeff_lamarche is offline   Reply With Quote
Old 10-31-2008, 07:24 PM   #3 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Germany, Munich
Posts: 246
rhuettl is on a distinguished road
Default

You have to fire the next responder so that the event delegation is working here. Here is a idea where you have to direct in...

Code:
if(self.nextResponder != nil &&  [self.nextResponder respondsToSelector:@selector(touchesBegan:withEvent:)]) 
	{
		[self.nextResponder touchesBegan:touches withEvent:event];
	}
Cheers
rhuettl is offline   Reply With Quote
Old 10-31-2008, 09:15 PM   #4 (permalink)
New Member
 
Join Date: Apr 2008
Posts: 420
jeff_lamarche is an unknown quantity at this point
Send a message via AIM to jeff_lamarche Send a message via Yahoo to jeff_lamarche
Default

Quote:
Originally Posted by rhuettl View Post
Code:
if(self.nextResponder != nil &&  [self.nextResponder respondsToSelector:@selector(touchesBegan:withEvent:)]) 
	{
		[self.nextResponder touchesBegan:touches withEvent:event];
	}
This could cause some issues in a UIScrollView, UITableView, or UIWebView subclass because of the way those classes temporarily interrupt the responder chain. If the gesture turns into a pan or zoom, you should not forward to the next responder unless you know for sure that the child UIScrollView/UITableView/UIWebView was hit, so you probably need to do a separate hit test before forwarding to the next responder. If the user touched and panned over a button, for example, you wouldn't want to forward it on because then the button would get triggered when the user meant to scroll the view.

I'd almost recommend maybe rethinking the UI. This can be done, but it's going to be a bear to handle and get all the various permutations right.
__________________
Check out my iPhone Dev Blog
You can send me e-mail at my forum username at mac dot com.
jeff_lamarche is offline   Reply With Quote
Old 11-03-2008, 06:48 AM   #5 (permalink)
New Member
 
Join Date: Oct 2008
Posts: 6
funkaster is on a distinguished road
Default

thanks!...
After reading both of your replies, I think I really should re-think my UI :-)

regards,
r./
funkaster is offline   Reply With Quote
Old 06-06-2009, 09:56 AM   #6 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 4
unfalkster is on a distinguished road
Default

Quote:
Originally Posted by funkaster View Post
thanks!...
After reading both of your replies, I think I really should re-think my UI :-)

regards,
r./
Discussing the problem of having a UIWebView inside a UITableView, I found out that if I set my UIWebView as the cell's backgroundView :
Code:
theCell.backgroundView = myWebView;
Then, the touches events are not passed to the webview.

Instead, if I add the webview as a subview of the contentView :
Code:
[theCell.contentView addSubView:myWebView];
Then, the touches events are passed, or at least I can touch a link in the webview and load it (I did not try for scrolling my webview which was disabled).

Hope that will help somebody :-)
unfalkster is offline   Reply With Quote
Reply

Bookmarks

Tags
scrollview, tableview, webview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 333
13 members and 320 guests
Absentia, cgokey, fiftysixty, givensur, heshiming, iGamesDev, linkmx, michaelhansen, mraalex, PixelInteractive, raihan.zbr, Sloshmonster
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,117
Posts: 402,891
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:08 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0