简体   繁体   English

UITableView不滚动

[英]UITableView doesn't scroll

So, this is my view: 所以,这是我的看法:

在此处输入图片说明

and this is my UItableViewDelegate and DataSource 这是我的UItableViewDelegate和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. 问题是UItableView无法滚动。 never. 决不。 I really can't figure out why... Someone can help me? 我真的不知道为什么...有人可以帮助我吗?

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). 明确地说,检查视图层次结构以查看视图是否与tableView重叠(即使alpha值为0.05的视图也可以识别并消化触摸)。

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. 建议您使用控制器的根视图,然后递归调用视图层次结构以NSLog记录图像的大小。

you can also do this with your tableView : 您也可以使用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. 如果您在其他所有事物面前都在滚动视图,那么您肯定会知道某个视图正在捕获该视图之前的触摸。

Try saying self.tableView.userInteractionEnabled = YES; 尝试说出self.tableView.userInteractionEnabled = YES; after you implement the clock view. 实现时钟视图后。

If this doesn't work, try [self.view bringSubviewToFront:self.tableView]; 如果这不起作用,请尝试[self.view bringSubviewToFront:self.tableView];

I tried to achieve a similar result and it works fine for me. 我试图达到类似的结果,并且对我来说效果很好。 Try to check you options 尝试检查您的选项

UITableViewOptions

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM