So I've got a ViewController, which has two Container Views. The top one is the main content. The bottom one is a banner that will hide/show on certain events.
The bottom one is positioned such that it is under the tab bar until the event occurs.
When the event occurs, the frame of the main view is shrank and the frame of the banner is repositioned, such that it appears to 'slide' into the view and become available.
The problem I'm having is, unless I resize the main view in the storyboard (which is not what I want), any resizing I do in code DOES reveal the banner, but the banner does not respond to touches. (Resizing in storyboard, it does respond.) It seems that there's some other view in front of it that's intercepting the touches, but what, and how do I fix it?
The main view controller:
func hideBanner() {
bannerViewController?.toggleBannerDisplay(show: false)
contentTableViewController?.toggleBannerDisplay(show: false)
}
func showBanner() {
bannerViewController?.toggleBannerDisplay(show: true)
contentTableViewController?.toggleBannerDisplay(show: true)
}
The content table view controller:
func toggleBannerDisplay(show: Bool) {
let tableView = self.view as! UITableView
UIView.animate(withDuration: 0.5, animations: {
if self.cancelApplyShowing == false && show == true {
let frame = tableView.frame
let newFrame = CGRect(x:frame.origin.x , y: frame.origin.y, width: frame.size.width, height: frame.size.height - 48)
tableView.contentSize = newFrame.size
tableView.frame = newFrame
self.cancelApplyShowing = true
} else if self.cancelApplyShowing == true && show == false {
let frame = tableView.frame
let newFrame = CGRect(x:frame.origin.x , y: frame.origin.y, width: frame.size.width, height: frame.size.height + 48)
tableView.contentSize = newFrame.size
tableView.frame = newFrame
self.cancelApplyShowing = false
}
})
}
The banner:
func toggleBannerDisplay(show: Bool) {
UIView.animate(withDuration: 0.5, animations: {
if self.cancelApplyShowing == false && show == true {
let frame = self.view.frame
let newFrame = CGRect(x: frame.origin.x, y: frame.origin.y - 48, width: frame.size.width, height: frame.size.height)
self.view.frame = newFrame
self.cancelApplyShowing = true
} else if self.cancelApplyShowing == true && show == false {
self.view.frame.origin.y += 48
self.cancelApplyShowing = false
}
})
}
For some reason, if I resize that main view, the hidden view becomes responsive (after animations of course).
Vimeo video: https://vimeo.com/246496442