开发者

TTScrollView with nested UIScrollView

I want to have two pages displayed: One contains an image, this should not be scrolable as the image fits the screen nicely. The second is a longer text which has to be scrolled vertically. I tried the classical approach of a big UIScrollView where I just change the offset of the x-value, yet this leaves me with the issue that the image is kind of lost and the user can scroll down there as well as drag the ScrollView diagonally, which looks very un-iPhone like.

So I turned to Three20 and implemented an approach with its TTScrollView. On one page I just render an image view that gets displayed and on the other page I nest a UIScrollView with the text. This works nice as long as you start from the image and switch pages to the ScrollView. Yet afterwards you are no longer able to switch back as the UIScrollView does not pass any touch events to the parent class (which would be the TTScrollView). There are some methods you can implement 开发者_JS百科to get the touches that happened (touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view ), yet I did not manage to get these to work and could not find any method in the TTScrollView to tell it to scroll one page back or forth anyway.

Did anybody experience the same problem and knows a solution? What are you supposed to do if you have multiple pages whose content does not have the same length?

I am glad for any hint, I have been working on this for hours already.


You could pass on the touches to its superview by:

-(void) touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view{
    if([self.superview respondsToSelector:@selector(touchesShouldBegin:withEvent:inContentView:)]){
       [self.superview performSelector:@selector(touchesShouldBegin:withEvent:inContentView:) withObject:touches withObject:event withObject:view];
    }
}

I will try to accomplish the same thing. I will let you know if I tried it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜