ios - 将 UIView 移动到新的 super View 并从 UITableViewCell 返回

标签 ios objective-c uitableview swift uiview

我有一个自定义的 UITableViewCell,其中有一个自定义的 UIView。当有人按下 UITableViewCell 时,UIView 将作为 subview 传输到新的 UIWindow。然后,当 UIWindow 被关闭时,我需要将 UIView 传输回所选的相同 UITableViewCell 中。 我试过使用这段代码:

(self.tableView.cellForRowAtIndexPath(self.tableView.indexPathForSelectedRow()!) as! ContentTableCell).replaceControls(self.expandedViewController.Controls)

其中 replaceControls() 是我的自定义表格单元格中的一个函数,它将给定 View 添加为 subview 并将其连接到适当的 @IBOutletself.expandedViewController.Controls 是自定义的 UIView

但是这不起作用并产生错误 CGAffineTransformInvert: singular matrix

最佳答案

如何使用 hidden 函数和 CATrasition 将所有应该设置在两个 View 中的对象放在一个 View 中。

  • 例如,您使用 @IBAction fun flipViews() 创建了 UIButton 的实例。并且您应该在 viewDidLoad()storyboard 中设置应该在 BackSideView 中设置为 hidden 的对象。


    func flipViews() { UIView.beginAnimations("ViewSwitch", context: nil) UIView.setAnimationDuration(0.6) UIView.setAnimationCurve(.EaseInOut) 如果 backSideObject1.hidden { frontSideObject1.hidden = true frontSideObject2.hidden = true frontSideObject3.hidden = true backSideObject1.hidden = false backSideObject2.hidden = false backSideObject3.hidden = false } 别的 { frontSideObject1.hidden = false frontSideObject2.hidden = false frontSideObject3.hidden = false backSideObject1.hidden = true backSideObject2.hidden = true backSideObject3.hidden = true } UIView.setAnimationTransition(.FlipFromLeft, forView: view, cache: true) UIView.commitAnimations() }

希望我的回答能帮到你。

关于ios - 将 UIView 移动到新的 super View 并从 UITableViewCell 返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29749954/

相关文章:

ios - 在 Swift 3 中相应部分下的 UiTableView 中显示列表

ios - 以编程方式更改 tabBar 项目?

objective-c - 如何处理临时 NSManagedObject 实例?

iOS——区分 NSDictionary 和 NSMutableDictionary?

ios - 在 segue 之前检查条件

iOS - UIButton 作为 UIAlertController 上的 subview 未触发事件

ios - 为什么滚动 UITableView 比滚动 UIScrollView 响应更快?

ios - 在 UITableViewCell 中将按钮右对齐

objective-c - 如何在 iOS 上的计时器内更新 UI?

pod 安装后 iOS 通用框架编译器版本发生变化