I have the following storyboard setup:
StoryBoard :
I'm hiding the navigation and tool bars upon tap, however the UITextView shifts up when the navigation bars disappear.
lyrics.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "show_fdw_bck"))
func show_fdw_bck () {
print("screen tapped")
if SongMgr.settings2 == false {
fwdappear.hidden = true
bckappear.hidden = true
navigationController?.navigationBarHidden = true
navigationController?.setToolbarHidden(true, animated: false)
//lyrics.frame = CGRect(x: 10, y: 80, width: self.view.frame.size.width - 20, height: self.view.frame.size.width)
SongMgr.settings2 = true
} else {
fwdappear.hidden = false
bckappear.hidden = false
navigationController?.navigationBarHidden = false
navigationController?.setToolbarHidden(false, animated: false)
//lyrics.frame = CGRect(x: 10, y: 0, width: self.view.frame.size.width - 20, height: self.view.frame.size.width)
SongMgr.settings2 = false
}
}
I attempted to change the order of objects in scene, moving the textview to bottom of View solves the problem, but it hides the UIButtons. Any help would be much appreciated.
The reason that your UITextView
shifts up is because the constraints remain the same. There are a couple of ways you can go about fixing this, one option will be to set an IBOutlet
for the top margin of your UITextView
and then setting the constant
property to be +64 (the height of the nav bar) of what it currently is.
Another way to do it is to redo your constraints for the UITextView in the storyboard and set different priorities to specific ones as needed.