提问人:Awais Shahid 提问时间:11/19/2019 更新时间:11/19/2019 访问量:169
将 .xib 视图添加为子视图后,视图按钮不再可单击
View buttons are not anymore clickable after adding a .xib view as subview
问:
我有一个视图控制器,其中显示了下面的卡片。我使用 .xib 视图从视图控制器的底部滑动,因为在视图控制器的视图中添加 .xib 视图作为子视图后,即使 .xib 视图折叠,视图控制器按钮也不再可单击。“cardViewController” 是 .xib 视图的名称。
var cardViewController:FrenchiasCardViewController!
func setupCard()
{
// Setup starting and ending card height
endCardHeight = self.view.frame.height * 0.9
startCardHeight = self.view.frame.height * 0.08
// Add Visual Effects View
visualEffectView = UIVisualEffectView()
visualEffectView.frame = self.view.frame
self.view.addSubview(visualEffectView)
// Add CardViewController xib to the bottom of the screen, clipping bounds so that the corners can be rounded
cardViewController = FrenchiasCardViewController(nibName:"FrenchiasCardViewController", bundle:nil)
self.view.addSubview(cardViewController.view)
cardViewController.view.frame = CGRect(x: 0, y: self.view.frame.height - startCardHeight, width: self.view.bounds.width, height: endCardHeight)
cardViewController.view.clipsToBounds = true
// Add tap and pan recognizers
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(NewAddressView.handleCardTap(recognzier:)))
let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(NewAddressView.handleCardPan(recognizer:)))
cardViewController.handleArea.addGestureRecognizer(tapGestureRecognizer)
cardViewController.handleArea.addGestureRecognizer(panGestureRecognizer)
}
let frameAnimator = UIViewPropertyAnimator(duration: duration, dampingRatio: 1) {
switch state {
case .expanded:
// If expanding set popover y to the ending height and blur background
self.cardViewController.view.frame.origin.y = self.view.frame.height - self.endCardHeight
self.visualEffectView.effect = UIBlurEffect(style: .dark)
case .collapsed:
// If collapsed set popover y to the starting height and remove background blur
self.cardViewController.view.frame.origin.y = self.view.frame.height - self.startCardHeight
self.visualEffectView.effect = nil
}
}
答: 暂无答案
评论