问题
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