【发布时间】:2019-02-06 10:56:16
【问题描述】:
当视图确实出现时,我正在显示一个视图,视图上有一个按钮没有被点击。动画工作得很好。
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 下看到。
【问题讨论】:
-
您是否尝试在连接到按钮的函数中设置断点?断点被命中了吗?
-
@waldrumpus 我在未执行的 IB Action 方法中放置了简单的打印语句,我的意思是在控制台中看不到任何内容。您现在可以看到有问题的 IB Action 代码。
-
您似乎已经正确测试了视图层次结构。但是您是否尝试过使用
view.bringSubview(toFront:)确保按钮位于最顶端? -
notificationView是带有您的按钮@IBAction func的自定义类吗?或者它只是你的视图控制器的一个子视图,而按下的按钮功能在视图控制器中? -
显示您在哪个视图上调用此操作以及如何调用? @GaneshPawar
标签: ios swift view uibutton ibaction