Ios 不兼容的指针类型返回';UITableViewCell*\uuuu strong&\x27;从结果类型为';UITableView*';当您尝试查看记录时
我正在以以下方式将Ios 不兼容的指针类型返回';UITableViewCell*\uuuu strong&\x27;从结果类型为';UITableView*';当您尝试查看记录时,ios,objective-c,sqlite,uitableview,Ios,Objective C,Sqlite,Uitableview,我正在以以下方式将SELECT查询结果加载到tableView中,但收到一条警告,提示指针类型不兼容 下面我的代码中有什么错误 提前谢谢你的建议 -(UITableView *)tableview : (UITableView *)tableview cellForRowAtIndexPath: (NSIndexPath *)indexPath { static NSString *CellIdentifier = @"cell"; UITableViewCell *cell = [ta
SELECT
查询结果加载到tableView
中,但收到一条警告,提示指针类型不兼容
下面我的代码中有什么错误
提前谢谢你的建议
-(UITableView *)tableview : (UITableView *)tableview cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableview dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:CellIdentifier];
NSInteger locationRow = indexPath.row;
cell.textLabel.text = [appDelegate.nameArray objectAtIndex:locationRow];
return cell; // error comes here
}
函数的返回类型错误。它应该返回
UITableView单元格*
,而不是UITableView*
-(UITableViewCell*)tableview:(UITableView *)tableview cellForRowAtIndexPath: (NSIndexPath *)indexPath;
希望有帮助 函数的返回类型错误。它应该返回
UITableView单元格*
,而不是UITableView*
-(UITableViewCell*)tableview:(UITableView *)tableview cellForRowAtIndexPath: (NSIndexPath *)indexPath;
希望有帮助 您将返回类型设置为
UITableView
,但它需要UITableViewCell
,因此您必须按以下方式进行更改
-(UITableViewCell *)tableview : (UITableView *)tableview cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableview dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSInteger locationRow = indexPath.row;
cell.textLabel.text = [appDelegate.nameArray objectAtIndex:locationRow];
return cell;
}
-(UITableViewCell*)tableview:(UITableView*)tableview cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*CellIdentifier=@“cell”;
UITableViewCell*单元格=[tableview dequeueReusableCellWithIdentifier:CellIdentifier];
如果(单元格==nil)
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:CellIdentifier];
}
NSInteger locationRow=indexPath.row;
cell.textLabel.text=[appDelegate.nameArray objectAtIndex:locationRow];
返回单元;
} 您将返回类型设置为
UITableView
,但它应为UITableViewCell
,因此您必须按如下所示进行更改
-(UITableViewCell *)tableview : (UITableView *)tableview cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableview dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSInteger locationRow = indexPath.row;
cell.textLabel.text = [appDelegate.nameArray objectAtIndex:locationRow];
return cell;
}
-(UITableViewCell*)tableview:(UITableView*)tableview cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*CellIdentifier=@“cell”;
UITableViewCell*单元格=[tableview dequeueReusableCellWithIdentifier:CellIdentifier];
如果(单元格==nil)
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:CellIdentifier];
}
NSInteger locationRow=indexPath.row;
cell.textLabel.text=[appDelegate.nameArray objectAtIndex:locationRow];
返回单元;
} 您需要检查您的退货类型。因为您正在返回
UITableViewCell
,但返回类型是UITableView
。有关更多信息,请参见代码中的这一行
-(UITableViewCell *)tableview : (UITableView *)tableview cellForRowAtIndexPath: (NSIndexPath *)indexPath
您需要检查您的退货类型。因为您正在返回
UITableViewCell
,但返回类型是UITableView
。有关更多信息,请参见代码中的这一行
-(UITableViewCell *)tableview : (UITableView *)tableview cellForRowAtIndexPath: (NSIndexPath *)indexPath
您可以更轻松地执行此操作,不要在cellForRowAtIndexPath方法中创建单元格,而是使用以下代码:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.table registerNib:[UINib nibWithNibName:@"MyCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"MyCellIdentifier"];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"MyCellIdentifier";
MyCell *cell = (MyCell*)[self.table dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
// Setup cell here
return cell;
}
您可以更轻松地执行此操作,不要在cellForRowAtIndexPath方法中创建单元格,而是使用以下代码:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.table registerNib:[UINib nibWithNibName:@"MyCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"MyCellIdentifier"];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"MyCellIdentifier";
MyCell *cell = (MyCell*)[self.table dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
// Setup cell here
return cell;
}
我仍然收到这个警告。我使用HVtable作为第三方工具 -(TableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath已展开:(BOOL)已展开{
static NSString *CellIdentifier = @"MYCELLUP";
UpcomingTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
NSArray *cellSubs = cell.contentView.subviews;
if (isExpanded){
[self tableView:tbView expandCell:cell withIndexPath:indexPath];
}
else{
[self removeExpendedContent:cellSubs];
}
if(ary_up_trp_typ.count >= 1){
cell.img_blk_plane.image = [UIImage imageNamed:@"page4_09.png"];
cell.img_day.image = [UIImage imageNamed:@"page4_09.png"];
cell.lbl_up_trp_typ.text = [ary_up_trp_typ objectAtIndex:indexPath.row];
cell.lbl_up_dt_to_frm.text = [ary_up_dt_to_frm objectAtIndex:indexPath.row];
cell.lbl_up_ct_st.text = [ary_up_ct_st objectAtIndex:indexPath.row];
cell.lbl_up_day.text = [ary_up_day objectAtIndex:indexPath.row];
}
return cell;
}我仍然收到这个警告。我使用HVtable作为第三方工具 -(TableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath已展开:(BOOL)已展开{
static NSString *CellIdentifier = @"MYCELLUP";
UpcomingTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
NSArray *cellSubs = cell.contentView.subviews;
if (isExpanded){
[self tableView:tbView expandCell:cell withIndexPath:indexPath];
}
else{
[self removeExpendedContent:cellSubs];
}
if(ary_up_trp_typ.count >= 1){
cell.img_blk_plane.image = [UIImage imageNamed:@"page4_09.png"];
cell.img_day.image = [UIImage imageNamed:@"page4_09.png"];
cell.lbl_up_trp_typ.text = [ary_up_trp_typ objectAtIndex:indexPath.row];
cell.lbl_up_dt_to_frm.text = [ary_up_dt_to_frm objectAtIndex:indexPath.row];
cell.lbl_up_ct_st.text = [ary_up_ct_st objectAtIndex:indexPath.row];
cell.lbl_up_day.text = [ary_up_day objectAtIndex:indexPath.row];
}
return cell;
}答案在错误描述中。检查您的返回类型。答案在错误描述中。检查您的退货类型。