Swift 当我向前或向后移动到下一页时,如何删除我从navigationController创建的uiview?

Swift 当我向前或向后移动到下一页时,如何删除我从navigationController创建的uiview?,swift,uiview,uinavigationcontroller,uinavigationitem,Swift,Uiview,Uinavigationcontroller,Uinavigationitem,我以编程方式创建了一个视图,并将其作为子视图添加到navigationController中。我现在面临的问题是,当我前进到下一页或上一页时,视图没有被删除。如何删除视图或仅在导航控制器的特定视图控制器中包含视图 self.footerView = UIView(frame: CGRectMake(0, UIScreen.mainScreen().bounds.height - 40, tableView.frame.size.width, 40)) self.footerV

我以编程方式创建了一个视图,并将其作为子视图添加到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)

在ViewController中创建相同的视图

let customView = //your view creation code.
self.view.addSubview(customView);
//this will add view to your viewcontroller's view, not in navigationContoller.
您可以删除该视图

customView.removeFromSuperview()

您可以粘贴视图创建代码并添加文件名为?'self.footerView=UIView(frame:CGRectMake(0,UIScreen.mainScreen().bounds.height-40,tableView.frame.size.width,40))的self.footerView.tag==1 let button=UIButton(类型:UIButtonType.Custom)button.frame=CGRectMake吗(footerView.frame.width/2-16,8,footerView.frame.width/2,30)button.layer.masksToBounds=true button.setTitle(“保存并继续”,forState:.Normal)button.setTitleColor(UIColor.whiteColor(),forState:.Normal)footerView.addSubview(button)self.navigationController?.view.addSubview(footerView)'编辑您的问题并粘贴代码,使其可读。谢谢您在哪里添加了此代码?请添加文件名添加viewcontroller类的完整代码我正在navigationcontroller中添加视图,而我使用的视图控制器是UITableviewcontroller