我有tableView与指标,但当我点击按钮它显示小popwindow图像我希望该图像应该与细胞对齐如果点击细胞在顶部然后弹出应该显示在顶部如果细胞clciked是middel然后根据.
现在我已经固定在屏幕上的一个位置.
当你按下任何单元格按钮addtoFave时,我想像普通的ipad应用程序一样,然后弹出按钮与该单元格对齐,任何想法如何完成.
这是我目前的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"ContentID %@",contentID);
CustomCell *cell = (CustomCell *) [tblSimpleTable cellForRowAtIndexPath:indexPath];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 312, 105)];
imgView.frame = CGRectMake((cell.frame.size.width/2)-(imgView.frame.size.width/2), (cell.frame.size.height/2)-(imgView.frame.size.height/2), 312, 105);
imgView.image=[UIImage imageNamed:@"popupj.png"];
[cell addSubview:imgView];
}
Run Code Online (Sandbox Code Playgroud)
但这显示单元格上的图像不是全部,当我点击其他单元格时,此图像显示在第一个单元格上我只想要选择哪个单元格应该显示给该单元格.
我有表视图,我想在选择时将图像添加到单元格,如果选择了新单元格,则将图像更改为选择单元格
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
cell = [self.tableView cellForRowAtIndexPath:indexPath];
cell.imageView.image=[UIImage imageNamed:@"Activity.png"];
}
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
cell = [self.tableView cellForRowAtIndexPath:indexPath];
cell.imageView.image=[UIImage imageNamed:@"Activity2.png"];
NSUInteger row = indexPath.row;
}
Run Code Online (Sandbox Code Playgroud)
这是我想要的代码,在我看来
if (indexPath.row==0) {
cell.imageView.image=[UIImage imageNamed:@"Activity2.png"];
NSLog(@"Cell Clicked row 0");
if(indexPath.row==1){
NSLog(@"Cell Clicked row 1 in 0");
cell.imageView.image=[UIImage imageNamed:@"Catalog"];
}
}
if (indexPath.row==1) {
cell.imageView.image=[UIImage imageNamed:@"Catalog2.png"];
NSLog(@"Cell Clicked row 1");
if(indexPath.row==0){
NSLog(@"Cell Clicked row 0 in 1");
cell.imageView.image=[UIImage imageNamed:@"Activity"];
}
}
Run Code Online (Sandbox Code Playgroud)
新代码添加了我选择新单元格时如何在单元格上显示图像.