gpt4 book ai didi

ios - 单击单元格时 UIView 位于 UITableView 之上?

转载 作者:行者123 更新时间:2023-11-29 03:03:35 25 4
gpt4 key购买 nike

我想做的是当单击 UITableViewCell 时在 UITableView 顶部显示一个较小的 View 。我不想转换到另一个 UIViewController,而是在 UITableView 顶部“弹出”一个 View ,其中将包含有关单击的 UITableViewCell 的更多信息。

我不认为我在寻找 UIAlertView,但我正在寻找一个可以放置标签、按钮、图片等的 UIView。

我希望我的术语是正确的。我还是个新手:)

莱昂

附注我所有的搜索都只是想出了 UIAlertView 的东西。

最佳答案

尝试使用 UITableView 的 didSelectRowAtIndexPath 委托(delegate)函数,代码未经测试给你一个想法:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Assuming view is at zero index of XIB file.
// this view will contain all lable and other controls
UIView *customView = (UIView *)[[NSBundle mainBundle] loadNibNamed:@"NameOfCustomViewXIBFile" owner:nil options:nil] objectAtIndex:0];

customView.transform = CGAffineTransformMakeScale(0.0f, 0.0f);
[self.view addSubView:customView];

[UIView animateWithDuration:0.5
animations:
^{
customView.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
}
];
}

希望对您有所帮助!


编辑:

删除此弹出窗口的动画:

    customView.transform = CGAffineTransformMakeScale(1.0f, 1.0f);

[UIView animateWithDuration:0.5
animations:
^{
customView.transform = CGAffineTransformMakeScale(0.0f, 0.0f);
}
];
[customView removeFromSuperView];

关于ios - 单击单元格时 UIView 位于 UITableView 之上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23018771/

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