开发者

UIScrollView not bouncing vertical when scrolled to top

i have a weird issue with a UIScrollView and a UIWebView in it. First my setup:

I subclassed a UIView and added the following code to it:


.h

@interface MySubclassedView : UIView {
    UIScrollView *scrollView;
    UIWebView *contentView;
}

@property(nonatomic,retain) UIWebView *contentView;

.m开发者_StackOverflow

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [self setupContentView];
    }
    return self;
}

setupContentView

-(void)setupContentView {

    // Content View
    self.contentView = [[UIWebView alloc] init];
    self.contentView.backgroundColor = [UIColor whiteColor];

    // ScrollView
    scrollView = [[UIScrollView alloc] init];
    scrollView.backgroundColor = [UIColor whiteColor];
    scrollView.alwaysBounceVertical = YES;
    [scrollView addSubview:self.contentView];
    [self addSubview:scrollView];
}

and my layoutSubViews

- (void)layoutSubviews {
    XLog(""); // something like NSLog
    [super layoutSubviews];
    scrollView.frame = CGRectMake(0,0, self.width, self.height);
    self.contentView.frame = CGRectMake(0,0, self.width, self.height);
}

The Problem with all of this is, that it bounces the first time when my scrollview is not completely scrolled to the top. after the scrollview is scrolled to top or bottom i cannot drag the view downwards but the layoutSubviews method gets called on and on as long as i'm dragging.

For better understanding i made a short screen video to demonstrate the behavior: http://www.screenr.com/Gy9

thanks for all help. if something is unclear, please let me know in the comments.


I'm really sorry I don't have something more helpful, but:

Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.

from:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html

Doesn't mean there's no way to make it work. But probably means you want to limit the amount of time you spend banging your head against the wall trying to get it to work.

That said, I have successfully embedded UIWebViews in UIScrollViews as long as one's userInteractionEnabled was set to NO.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜