简体   繁体   中英

UITableView doesn't scroll

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?

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.

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

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

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

UITableViewOptions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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