![](/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.