我有一个自定义的 UITableViewCell
,其中有一个自定义的 UIView
。当有人按下 UITableViewCell
时,UIView
将作为 subview 传输到新的 UIWindow
。然后,当 UIWindow
被关闭时,我需要将 UIView
传输回所选的相同 UITableViewCell
中。
我试过使用这段代码:
(self.tableView.cellForRowAtIndexPath(self.tableView.indexPathForSelectedRow()!) as! ContentTableCell).replaceControls(self.expandedViewController.Controls)
其中 replaceControls()
是我的自定义表格单元格中的一个函数,它将给定 View 添加为 subview 并将其连接到适当的 @IBOutlet
。 self.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/