Question

I have a UIWebView on my tablecells. There are large content and it should be scrollable.

But the webview prevents Tableview didselect delegate. How to overcome this. Ihf I make userinteractionenabled=NO; scrolling is not working.

Any solution please help. Thanks in advance.

Was it helpful?

Solution

Try using the override of hitTest

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
    id hitView = [super hitTest:point withEvent:event];

    if (hitView == self) {
        return nil;
    } else {
        return hitView;
    }
}

OTHER TIPS

Your design is definitely bad: Apple explicitly says in the UIWebView class reference, that you should not add UIWebViews to table cells. Also, as the web view internally manages an UIScrollView, which captures all the touches. So the only way to do what you want is to subclass UIWebView and override the touch management methods. This is also not advisable, as UIWebView is one of the few classes which are not to be subclassed according to Apple.

You have to seriously reconsider your design pattern.

I recommend adjusting the size of the cell to the content size of the web view. Then set webView.scrollView.scrollEnabled to NO.

This allows the user to scroll through the whole content just in the table view. Two nested scroll views scrolling in the same directions are not advisable because the user can't easily define where the scrolling happens.

As for the selection behavior, I guess you'll have to decide whether you want cell selection or webView interactivity (link tapping etc). If you go for cell selection, setting webView.userInteractionEnabled = NO should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top