gpt4 book ai didi

ios - 如何在 iPhone 中将 ImageView 的位置设置为 UITableViewCell 的中心

转载 作者:行者123 更新时间:2023-11-28 18:11:41 29 4
gpt4 key购买 nike

我有带 Indicator 的 tableView 但是当我点击按钮时它显示小的 popwindow 图像我希望如果点击的单元格在顶部那么图像应该与单元格对齐然后弹出窗口应该显示在顶部如果单元格点击是 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];

}

但是当我点击其他单元格时,这会在第一个单元格上显示图像,但当我单击其他单元格时,此图像仅显示在第一个单元格上,我希望选择的单元格应显示给该单元格。

最佳答案

首先添加这一行 myImageView.center = cell.center; 并在 cell.contentView 中添加您的 myImageView

您也可以将这段用于显示图像的代码放在UITableViewCell 的中心。

myImageView.center = CGPointMake(cell.contentView.bounds.size.width/2,cell.contentView.bounds.size.height/2);

关于ios - 如何在 iPhone 中将 ImageView 的位置设置为 UITableViewCell 的中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17463571/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com