ToucheSBegind在iOS 12中调用,但在iOS 13中未调用
我的ToucheSBegind在iOS 12中调用,但在iOS 13中未调用,ios,uigesturerecognizer,touchesbegan,ios13,Ios,Uigesturerecognizer,Touchesbegan,Ios13,我的AppDelegate中有一个touchsbegind方法。我用它来检测状态栏中的点击。我在那里呆了很长时间,效果很好。在iOS 13 Beta发布之前 自从使用iOS 13touchsbegind以来,就停止调用。我的应用程序中没有其他与手势相关的内容发生更改,我的AppDelegate中也没有任何内容发生更改。除了在iOS 12中调用touchsbegind,而不是在iOS 13中调用,我真的没有太多事情要做 到目前为止没有运气,所以我在这里分享这一点,以防其他人有相同或类似的问题 更
AppDelegate
中有一个touchsbegind
方法。我用它来检测状态栏中的点击。我在那里呆了很长时间,效果很好。在iOS 13 Beta发布之前
自从使用iOS 13touchsbegind
以来,就停止调用。我的应用程序中没有其他与手势相关的内容发生更改,我的AppDelegate
中也没有任何内容发生更改。除了在iOS 12中调用touchsbegind
,而不是在iOS 13中调用,我真的没有太多事情要做
到目前为止没有运气,所以我在这里分享这一点,以防其他人有相同或类似的问题
更新:1 我发现以下问题是半相关的,并将我引向苹果iOS 13的新版本。这些问题都不能解释为什么没有调用
touchesbreated
。据我所知,到目前为止,UISceneDelegate
还没有找到为什么没有调用touchsbegind
我最近也有同样的问题。我花了几个小时才弄明白。
我在主窗口顶部创建了另一个UIWindow,用于显示应用程序通知/警报。由于某些原因,当使用ios 13时,它会吃掉所有的触摸动作。我的解决办法是只在最上面的一个上禁用用户交互。但这意味着您显然无法使用通知/警报进行任何用户交互。这就是我正在做的,可能不是很好,但到目前为止,这是唯一有效的解决方案。乐于接受改进
- 创建内容大于其框架的TableViewController
- 显示“查看”时,滚动到“表格”视图的末尾
- 将TableViewController的框架设置为与StatusBarFrame相同,并将其添加到窗口的根viewcontroller
- 在scrollViewShouldScrollToTop中,处理ScrollToTop事件并滚动到末尾以获取下一个事件
- 在状态栏帧更改时,更新TableViewController的帧
你找到什么了吗?一直都有同样的问题,但还没能解决。@Miguel,还没有,但如果我解决了,我会在这里更新。@Xeaza谢谢你的研究。我也有同样的问题,似乎在iOS 13上,应该在SceneDelegate上检测到点击,但我认为这意味着应用程序必须放弃对
class ScrollToTopViewController: UITableViewController {
private let numberOfRow = 2
private let cellIdentifier = "empty"
override func viewDidLoad() {
super.viewDidLoad()
tableView.allowsSelection = false
tableView.separatorColor = .clear
tableView.backgroundColor = .clear
tableView.showsVerticalScrollIndicator = false
tableView.showsHorizontalScrollIndicator = false
tableView.register(UITableViewCell.self, forCellReuseIdentifier: cellIdentifier)
view.autoresizingMask = []
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
scrollToBottom()
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return view.frame.size.height
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return numberOfRow
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier) ?? UITableViewCell()
cell.backgroundColor = .clear
return cell
}
override func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self.scrollToBottom()
}
print("HANDLE SCROLL TO TOP")
return true
}
private func scrollToBottom() {
tableView.scrollToRow(at: IndexPath(row: numberOfRow - 1, section: 0), at: .bottom, animated: false)
}
}
private let scrollToTopVC = ScrollToTopViewController()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
NotificationCenter.default.addObserver(self,
selector: #selector(updateScrollToTopVC),
name: UIApplication.didChangeStatusBarFrameNotification,
object: nil)
return true
}
func applicationDidBecomeActive(_ application: UIApplication) {
updateScrollToTopVC()
}
@objc
private func updateScrollToTopVC() {
guard let viewController = window?.rootViewController else {
return
}
let statusBarFrame: CGRect
if #available(iOS 13.0, *) {
statusBarFrame = UIApplication.shared.keyWindow?.windowScene?.statusBarManager?.statusBarFrame ?? .zero
} else {
statusBarFrame = UIApplication.shared.statusBarFrame
}
scrollToTopVC.view.frame = statusBarFrame
viewController.addChild(scrollToTopVC)
viewController.view.addSubview(scrollToTopVC.view)
scrollToTopVC.didMove(toParent: viewController)
}