Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
647 views
in Technique[技术] by (71.8m points)

iphone - UITableView does not respond to scrolling the first time it's loaded

I have found that the first time a UITableView loads, it does not respond to scrolling touches -- if it does not have more rows than fit on the screen. If I close the view, then reopen the same object -- it will now respond to touches -- even though it contains the same number of rows.

I am not doing anything more than responding to the UITableViewDataSource methods for the number of rows, and generating the rows themselves. I am reloading the table every time the view appears.

Can anyone explain such behavior?


I am creating the cells like so:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
  static NSString *tableId = @"NewIndexTableId";
  Note *note = [notes objectAtIndex:[indexPath row]];

  UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:tableId];

  if (cell == nil)
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:tableId] autorelease];

  cell.textLabel.text = note.text;
  cell.detailTextLabel.text = [note changedDelta]; 
  cell.accessoryView = multipleAccounts ? [note.account imageView] : nil;

  return cell;  
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had same problem. Bounce Scroll was enabled in IB, but still no love. I had to set it in the code ( in viewDidLoad ) like so...

self.myTableView.bounces = YES;

Hope this helps ;-)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...