Objective c 如何从自定义tableviewCell中的按钮分离
我正在为当地一家足球俱乐部开发一个应用程序。在屏幕上,我想以网格的形式显示所有玩家。当你点击网格内的玩家照片时,你会得到关于该玩家的更多信息。 我正在使用customTableViewCell。此tableView单元格包含6个按钮。在每个按钮后面,你可以找到一些玩家信息。我正在设置网格中的玩家图像,如下所示。首先,我的custumTableViewCell中有一个方法Objective c 如何从自定义tableviewCell中的按钮分离,objective-c,ios,uitableview,core-data,nsfetchedresultscontroller,Objective C,Ios,Uitableview,Core Data,Nsfetchedresultscontroller,我正在为当地一家足球俱乐部开发一个应用程序。在屏幕上,我想以网格的形式显示所有玩家。当你点击网格内的玩家照片时,你会得到关于该玩家的更多信息。 我正在使用customTableViewCell。此tableView单元格包含6个按钮。在每个按钮后面,你可以找到一些玩家信息。我正在设置网格中的玩家图像,如下所示。首先,我的custumTableViewCell中有一个方法 -(void)setImage:(UIImage *)image forPosition:(NSUInteger)positi
-(void)setImage:(UIImage *)image forPosition:(NSUInteger)position{
if(position == 1){
[_btnPlayer1 setImage:image forState:UIControlStateNormal];
}else if(position == 2){
[_btnPlayer2 setImage:image forState:UIControlStateNormal];
}else if(position == 3){
[_btnPlayer3 setImage:image forState:UIControlStateNormal];
}else if(position == 4){
[_btnPlayer4 setImage:image forState:UIControlStateNormal];
}else if(position == 5){
[_btnPlayer5 setImage:image forState:UIControlStateNormal];
}else if(position == 6){
[_btnPlayer6 setImage:image forState:UIControlStateNormal];
}
}
在我的CellForRowAtIndexPath中,我正在做以下工作
NSInteger frcRow = indexPath.row * IMAGES_PER_ROW; // row in fetched results controller
for (int col = 1; col <= IMAGES_PER_ROW; col++) {
NSIndexPath *path = [NSIndexPath indexPathForRow:frcRow inSection:0];
Team *team = [self.fetchedResultsController objectAtIndexPath:path];
NSData *imgData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:team.image]];
UIImage *image;
if (imgData == nil) {
// default image
image = [UIImage imageWithContentsOfFile:@"keeperNil.jpg"];
} else {
image = [UIImage imageWithData:imgData];
}
[cell setImage:image forPosition:col];
frcRow ++;
}
return cell;
NSInteger frcRow=indexPath.row*每行图像;//获取结果控制器中的行
对于(int col=1;col这是实现您想要做的事情的错误方式。找到像Three20这样的照片查看器(以Three20为例,它很旧,没有弧,Git上有更好的替代方案),然后根据每个玩家照片的选择切换到新的视图
如果你真的想(尽管在我看来,这是一个糟糕的设计),你可以连接6个按钮并标记它们,然后根据所选的按钮标记选择一个播放器,但这似乎并不是UITableView的最佳用途