UIWebView不会滚动显示堆叠视图,子视图 [英] UIWebView won't scroll with stacked views, subviews

查看:59
本文介绍了UIWebView不会滚动显示堆叠视图,子视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个可动态构建大量堆叠视图的应用程序,最初遇到的事件处理问题是这里。该职位解决了我的大部分问题,但我仍然遇到一个问题。当用户单击rss feed项目的摘要时,我仅用一个关闭按钮就创建了几乎全屏的Web视图。关闭按钮有效,但Web视图拒绝滚动。我在上面链接中描述的代码上使用了一种变体,该变体旨在用于那些屏幕始终为1024x768但无需处理事件的屏幕上的屏幕和小工具,但是这些屏幕上的其他视图和按钮处理事件。一个屏幕具有一个永不更改的基本模板,而顶部的另一个屏幕却可以更改。处理小工具事件调度的代码是:

  @implementation ContainerView 


-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {

for(int i = self.subviews.count-1; i> = 0; i-- ){
UIView * view = [self.subviews objectAtIndex:i];

BOOL isContainerView = [view isMemberOfClass:[ContainerView class]];
if(isContainerView){
return [super hitTest:point withEvent:event];
}
else {
CGPoint viewPoint = [view convertPoint:point fromView:self];
if([viewpointInside:viewPoint withEvent:event]){
返回视图;
}
}
}

返回nil;
}

@end

这可以正确地将事件分配给 Btn 1和 Btn 2(见图)。我还看到了相同的代码,当我尝试滚动它时会返回我的UIWebVIew,但仍然无法滚动。
以下是视图如何堆叠的示意图:



关系图



也许UIWebView滚动是以某种特殊的方式处理的,可以绕过hitTest黑客攻击?他们只能说的是 UIWebView进行了大量自定义的触摸处理,使其难以捉住hitTest。因此,如果您遇到这种情况并想使用此hitTest替代解决方案,请不要指望它适用于UIWebView。在可能的情况下,我可能必须进行一些设计更改才能不以这种方式堆叠我的视图。


I'm working on an app the builds a lot of stacked views dynamically and I initially had event handling problems described here. That post solved most of my problems but I still have one issue. When a user clicks on a summary of an rss feed item, I create an almost-full screen web view with just a single "close" button. The close button works but the web view refuses to scroll. I use a variation on the code described in the the above link that is meant to work for "screens" and "gadgets" on those screens where the screens are always 1024x768 but never need to deal with events but other views and buttons on those screens do deal with events. A "screen" has a base template that never changes and another "screen" on top that does change. The code to handle the "gadget" event dispatching is:

@implementation ContainerView


- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {

for (int i=self.subviews.count-1; i >= 0; i--) {
    UIView *view = [self.subviews objectAtIndex:i];

    BOOL isContainerView = [view isMemberOfClass:[ContainerView class]];
    if (isContainerView) {
        return [super hitTest:point withEvent:event];
    }
    else {
        CGPoint viewPoint = [view convertPoint:point fromView:self];
        if ([view pointInside:viewPoint withEvent:event]) {
            return view; 
        }
    }
}

return nil;
}

@end

This correctly dispatches events to "Btn 1" and "Btn 2" (see diagram). I also see that this same code returns my UIWebVIew when I try to scroll it but it still doesn't scroll. The following is a diagram of how the views stack up:

diagram

Maybe UIWebView scrolling is handled in some special way that circumvents the hitTest hacking?

解决方案

I sent a support email to Apple about this and all they could really say was "UIWebView does a lot of custom touch handling that makes it elusive to catch with hitTest". So, if you have this situation and want to use this hitTest override solution, don't expect it to work for UIWebView. In may case, I'm probably going to have to make some design changes to not stack my views this way.

这篇关于UIWebView不会滚动显示堆叠视图,子视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆