不会从自定义视图调用IB操作

问题描述 投票:0回答:1

我在显示视图时显示视图,视图上有一个按钮没有被点击。动画工作得非常好。

func checkNotificationPermission(){

        if #available(iOS 10.0, *) {

            UNUserNotificationCenter.current().getNotificationSettings { (settings) in
                if settings.authorizationStatus == .authorized{
                    print("ProfileVC permission granted for notification")
                }else{

                    DispatchQueue.main.sync {

                        self.productCollectionView.isUserInteractionEnabled = false
                        UIView.animate(withDuration: 1, delay: 3, options: [.transitionFlipFromTop, .allowUserInteraction], animations: {

                                self.notificationView.frame = CGRect(x: 16, y: (UIScreen.main.bounds.size.height - 180), width: (UIScreen.main.bounds.size.width - 32), height: 150)

                        }, completion: { (isCompleted) in

                            UIView.animate(withDuration: 1, delay: 10, options: [.transitionFlipFromTop, .allowUserInteraction], animations: {

                                    self.notificationView.frame = CGRect(x: 16, y: UIScreen.main.bounds.size.height, width: (UIScreen.main.bounds.size.width - 32), height: 150)

                            }, completion: { (isCompleted) in
                                self.productCollectionView.isUserInteractionEnabled = true
                            })
                        })
                    }
                    print("ProfileVC permission not granted for notification")
                }
            }
        }else{
            // Fallback on earlier versions
            if UIApplication.shared.isRegisteredForRemoteNotifications {
                print("ProfileVC APNS-YES")
            } else {
                print("ProfileVC APNS-NO")
            }
        }
    }

IBAction在那里,连接也在那里。

@IBAction func setttingButtonPressed(_ sender: UIButton) {
    print("setting button pressed")

}

我查看了调试器,自定义视图显示了集合视图的顶部,您可以在customView下看到它。

Screen shot

ios swift view uibutton ibaction
1个回答
-1
投票

检查isUserInteractionEnabled以查看您添加的视图。它必须是true

您可以在视图调试器本身中调试此属性

© www.soinside.com 2019 - 2024. All rights reserved.