[英]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;
这应该解决问题!!
在下面的方法中,返回的行数多于您在设备/模拟器中看到的行数:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// return 12;
}
你必须像self一样声明表的属性委托:
self.miTableView.delegate = self
您可以在viewDidLoad函数中执行此操作。
不要忘记扩展到UITableViewDelegate
上面没有任何内容对我有用。 最后我简单地说
self.miTableView.reloadData()
到ViewDidLoad()......一切正常。
也许是因为我使用
self.miTableView.rowHeight = UITableViewAutomaticDimension
也许这是必要的重新加载...希望这有帮助
如果 class 是以编程方式创建的并且没有 xib,则可以通过在 ObjectiveC 中添加到 viewWillAppear(而不是 viewDidLoad)来直接解决滚动问题:
`self.tableView.scrollEnabled=YES;`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.