2012-09-04 129 views
2

我有一個UIScrollView,我在其中顯示推文。 scrollView包含在一堆視圖中,其中最後一個有4個手勢識別器。UIScrollView沒有響應觸摸

- (void) createTimeLine:(NSArray*)timeline 
{ 
    CGRect rect = CGRectMake(0, 0, 463, 150); 
    NSInteger i = 0; 
    NSLog(@"timeline objects: %d", timeline.count); 
    self.scrollView.contentSize = CGSizeMake(463, timeline.count * 150); 
    for (NSDictionary *d in timeline) { 
     SingleTwitViewController *c = [[SingleTwitViewController alloc] initWithAsingleTwit:d]; 
     rect.origin.y = i * 150; 
     c.view.frame = rect; 
     [scrollView addSubview:c.view]; 
     [scrollView bringSubviewToFront:c.view]; 
     i += 1; 
    } 
} 

有在時間軸20個對象,並且所述第一4是可見的:

滾動視圖如下填充。但是,scrollView不會滾動,手勢識別者操縱觸摸。

scrollEnabled屬性設置爲YES,但由於某種原因,這似乎不起作用。

contentSize設置爲463 * 3000,它比它自己的scrollView小得多,但它仍然不會滾動。

任何想法?

+0

你的'userInteractionEnable'設爲對於你的scrollView和你的子視圖來說是YES? – MaTTP

回答

0

嘗試這些,

scrollView.userInteractionEnabled=YES; 

內容大小應該比滾動視圖幀大小的更大...... 所以設置內容大小大...