UITableView doesn't scroll

不想你离开。 提交于 2019-12-06 12:26:32

问题


So, this is my view:

and this is my UItableViewDelegate and DataSource

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 20;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"course"];
    cell.textLabel.text = [NSString stringWithFormat:@"%i" ,arc4random() % 10];
    cell.detailTextLabel.text = [NSString stringWithFormat:@"%i" ,arc4random() % 10];
    return cell;
}

And this is the result:

The problem is that the UItableView doesn't scroll. never. I really can't figure out why... Someone can help me?


回答1:


I've seen similar thing in and every time I've seen this behaviour it was because some view were capturing the touches.

In clear, check your view Hierarchy to see if a view overlaps your tableView, (even a view with an alpha of 0.05 can recognize and digest touch).

I suggest you take the root view of your controller and to recursively call on the view Hierarchy to NSLog the size of your images.

you can also do this with your tableView :

- (void)bringSubviewToFront:(UIView *)view
[self.view bringSubviewToFront:self.tableView];

If your tableview is scrolling when in front of every thing else, you will know for shure that some view is capturing the touch before the table view.




回答2:


Try saying self.tableView.userInteractionEnabled = YES; after you implement the clock view.

If this doesn't work, try [self.view bringSubviewToFront:self.tableView];




回答3:


I tried to achieve a similar result and it works fine for me. Try to check you options



来源:https://stackoverflow.com/questions/13733354/uitableview-doesnt-scroll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!