![](/img/trans.png)
[英]Incompatible pointer types assigning to 'UIDatePicker *' from 'UIPopoverController *'
[英]Incompatible pointer types assigning to 'TableViewCell' from 'UITableViewCell'
我正在尝试此代码并得到警告以下
不兼容的指针类型从“ UITableViewCell”分配给“ GuideTableViewCell”
排队
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"BusinessTableViewCell"];
完整代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
BusinessTableViewCell * cell = [self.tableView dequeueReusableCellWithIdentifier:@"BusinessTableViewCell"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"BusinessTableViewCell"];
}
BusinessInfo * business = self.businesses[indexPath.row];
cell.business = business;
return cell;
}
也尝试过
BusinessTableViewCell *cell = [[UITableViewCell alloc]initWithStyle: UITableViewCellStyleDefault reuseIdentifier:@"BusinessTableViewCell"];
仍然遇到错误,任何人都可以给我一些帮助。
谢谢
您的代码中有两个问题。 它应该是:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
BusinessTableViewCell * cell = (BusinessTableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:@"BusinessTableViewCell"];
if(!cell)
{
cell = [[BusinessTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"BusinessTableViewCell"];
}
BusinessInfo * business = self.businesses[indexPath.row];
cell.business = business;
return cell;
}
dequeueReusableCellWithIdentifier
转换为适当的类。 您收到错误,因为您的代码可能无法正常工作。
您的代码需要一个BusinessTableViewCell。 您创建一个UITableViewCell。 您应该创建一个BusinessTableViewCell。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.