【发布时间】:2016-01-06 08:31:09
【问题描述】:
我以编程方式创建了一个视图并将其作为子视图添加到 navigationController。我现在面临的问题是当我前进到下一页或上一页时视图没有被删除。可以做些什么来删除视图或仅将视图包含在导航控制器的特定视图控制器中?
self.footerView = UIView(frame: CGRectMake(0, UIScreen.mainScreen().bounds.height - 40, tableView.frame.size.width, 40))
self.footerView.tag == 1
footerView.backgroundColor = themeColor
let totalLabel = UILabel(frame: CGRectMake(16, 8, footerView.frame.width/2, 30))
totalLabel.text = "Rs. 200"
totalLabel.textColor = UIColor.whiteColor()
let button = UIButton(type:UIButtonType.Custom)
button.frame = CGRectMake(footerView.frame.width/2 - 16, 8, footerView.frame.width/2, 30)
button.layer.masksToBounds = true
button.setTitle("Save and Continue", forState: .Normal)
button.setTitleColor(UIColor.whiteColor(), forState: .Normal)
button.addTarget(self, action: "saveButonPressed:", forControlEvents: .TouchUpInside)
button.layer.borderColor = UIColor.whiteColor().CGColor
button.layer.borderWidth = 2
button.layer.cornerRadius = 8
footerView.addSubview(totalLabel)
footerView.addSubview(button)
self.navigationController?.view.addSubview(footerView)
【问题讨论】:
-
可以粘贴视图创建和添加的代码,文件名吗?
-
'self.footerView = UIView(frame: CGRectMake(0, UIScreen.mainScreen().bounds.height - 40, tableView.frame.size.width, 40)) self.footerView.tag = = 1 let button = UIButton(type:UIButtonType.Custom) button.frame = CGRectMake(footerView.frame.width/2 - 16, 8, footerView.frame.width/2, 30) button.layer.masksToBounds = true 按钮。 setTitle("保存并继续", forState: .Normal) button.setTitleColor(UIColor.whiteColor(), forState: .Normal) footerView.addSubview(button) self.navigationController?.view.addSubview(footerView)'
-
编辑您的问题并粘贴代码,使其可读。谢谢
-
您在哪里添加了此代码?请添加文件名
-
添加视图控制器类的完整代码
标签: swift uiview uinavigationcontroller uinavigationitem