iBu*_*ilt 3 cocoa-touch objective-c ios
我是iOS编程的新手,我创建了一个customcell类,因此没有调用awakefromnib方法,因此IBOutlets即将发布!它让我发疯!请帮忙!我正在使用情节提要而不是Xibs。
Ric*_*ick 10
我最近遇到了这个问题,这是由于错误地注册了单元所导致的。要从UITableViewCell笔尖加载,您需要像这样注册:
override func viewDidLoad() {
super.viewDidLoad()
// .....
let cellNib = UINib(nibName: "YourCellNibName", bundle: nil)
tableView.register(cellNib, forCellReuseIdentifier: "YourCellIdentifier")
}
Run Code Online (Sandbox Code Playgroud)
我也遇到了这个问题,问题是我正在打电话:
self.collectionView.register(CollectionCell.self, forCellWithReuseIdentifier: "CollectionCell")
Run Code Online (Sandbox Code Playgroud)
即使我实际上已经在故事板中添加了集合视图单元格。如果是这种情况,那么注册该类是不必要的,并且在单元出队时会导致所有 IBOutlets 为零
如果您希望从 xib 实例化单元格,那么您的tableView:cellForRowAtIndexPath:方法中的实现是错误的。
您需要做几件事:
确保Identifier单元格的 被设置为 xib 中一个很好的唯一值。(nb cell 不是一个很好的唯一名称,仅用于此示例)
在您的tableView:cellForRowAtIndexPath:方法中,确保使用此重用标识符创建单元格
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
// configure cell
return cell;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5371 次 |
| 最近记录: |