未从自定义视图调用IB操作

时间:2018-08-31 11:52:43

标签: ios swift view uibutton ibaction

当一个视图确实出现时,我正在显示一个视图,视图上有一个未被点击的按钮。动画效果很好。

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")

}

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

Screen shot

1 个答案:

答案 0 :(得分:-1)

检查BroadcastReceiver中已添加的视图。它必须是isUserInteractionEnabled

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