繁体   English   中英

UITableview 不滚动?

[英]UITableview Not scrolling?

我在cellForRowAtIndex方法中使用了以下代码,但tableview没有滚动?

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView1 dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}

cell.textLabel.adjustsFontSizeToFitWidth = YES;        

cell.textLabel.text = [NSString stringWithFormat:@"...%@...", hit.neighboringText];

return cell;

查看您的xib并检查这些内容。请参见下图

在此输入图像描述

self.tableView.autoresizingMask = UIViewAutoresizing.FlexibleHeight;

这应该解决问题!!

试试这个会清除你的问题

self.myTableView.bounces = YES;

更多信息查看此帖子

在下面的方法中,返回的行数多于您在设备/模拟器中看到的行数:

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

你必须像self一样声明表的属性委托:

self.miTableView.delegate = self

您可以在viewDidLoad函数中执行此操作。

不要忘记扩展到UITableViewDelegate

上面没有任何内容对我有用。 最后我简单地说

self.miTableView.reloadData()

到ViewDidLoad()......一切正常。

也许是因为我使用

 self.miTableView.rowHeight = UITableViewAutomaticDimension

也许这是必要的重新加载...希望这有帮助

在我的例子中,SuperView 是 User Interaction Enabled not selected 确保 User Interaction Enabled Checkmark For SuperView

在此处输入图像描述

如果 class 是以编程方式创建的并且没有 xib,则可以通过在 ObjectiveC 中添加到 viewWillAppear(而不是 viewDidLoad)来直接解决滚动问题:

`self.tableView.scrollEnabled=YES;`

暂无
暂无

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

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