简体   繁体   English

trailingSwipeActionsConfigurationForRowAt 未在 Xcode 中的 iPhone 模拟器上调用 - 适用于 iPad 模拟器

[英]trailingSwipeActionsConfigurationForRowAt not being called on iPhone simulator in Xcode - works on iPad simulator

Recently updated Xcode to 13.4.1.最近将 Xcode 更新到 13.4.1。

When I compile to any iPhone simulator, swiping a tableViewCell does not trigger trailingSwipeActionsConfigurationForRowAt.当我编译到任何 iPhone 模拟器时,滑动 tableViewCell 不会触发 trailingSwipeActionsConfigurationForRowAt。 Works fine on iPad simulator and on a real iPhone.在 iPad 模拟器和真正的 iPhone 上运行良好。

func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {

    return true

} }

func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {

    // isn't getting this far on iPhone simulator!
    
    let contextItem1 = UIContextualAction(style: .destructive, title: "Edit") {  (contextualAction, view, completionHandler) in
        self.edit(at: indexPath.adjustRowIndex())
        completionHandler(true)
    }
    

    contextItem1.backgroundColor = UIColor.HIIT.green
    
    let contextItem2 = UIContextualAction(style: .destructive, title: "Delete") {  (contextualAction, view, completionHandler) in
        
        let row = self.data[indexPath.adjustRowIndex().row]
        self.alert(data: AlertDataObjects.delete(name: row.name), cancelCompletion: nil) {
            self.deleteRow(at: indexPath.adjustRowIndex())
            completionHandler(true)
        }
    }
    contextItem2.backgroundColor =  UIColor.red
    
    let swipeActions = UISwipeActionsConfiguration(actions: [contextItem1, contextItem2])

    swipeActions.performsFirstActionWithFullSwipe = true
    return swipeActions
}

} }

This seemed to be happening because I was running Xcode in Rosetta mode (on an M1 MacBook).这似乎正在发生,因为我在 Rosetta 模式下(在 M1 MacBook 上)运行 Xcode。

Finder > Applications > Control + Click Xcode > Get Info - Uncheck Open in Rosetta Mode checkbox. Finder > Applications > Control + 单击 Xcode > Get Info - 取消选中 Open in Rosetta Mode 复选框。

Rosetta Mode off: delegate behaviour as expected, trailingSwipeActionsConfigurationForRowAt method called and simulator working as expected Rosetta Mode on: trailingSwipeActionsConfigurationForRowAt method called once on very first run of app / cell swipe, and after that, method not called at all. Rosetta 模式关闭:按预期委托行为,调用 trailingSwipeActionsConfigurationForRowAt 方法,模拟器按预期工作 Rosetta 模式打开:在第一次运行应用程序/单元格滑动时调用一次 trailingSwipeActionsConfigurationForRowAt 方法,之后,根本不调用方法。 (canEditRowAt is called normally) (canEditRowAt 正常调用)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Xcode 模拟器中重复调用 didUpdateLocations - didUpdateLocations being called repeatedly in Xcode simulator Xcode 我的应用程序无法在 iPad 模拟器中运行,但适用于 iPhone 模拟器 - Xcode my app won't work in the iPad simulator but works on iPhone simulators NSUrlRequest可在模拟器中使用,但不能在iPhone上使用 - NSUrlRequest works in simulator but not on iphone UILabel.attributedText在iPhone Simulator上不显示(但在iPad Simulator上可用) - UILabel.attributedText doesn't show on iPhone Simulator (but works on iPad Simulator) 带有iOS 9.3的XCode 7-约束在iPhone模拟器中有效,但在iPad模拟器中运行时会添加边距 - XCode 7 with iOS 9.3 - Constraints Works in iPhones Simulator But When Running in an iPad Simulator a Margin is Added Swift XCode-情节提要中的更改未反映在iPhone模拟器中 - Swift XCode - Changes in storyboard aren't being reflected in the iPhone simulator CoreData在使用xCode 6的iOS 8 Swift中的我的模拟器上运行但在我的iPhone上不可用 - CoreData works on my simulator in but not on my iPhone in iOS 8 Swift using xCode 6 iPhone应用程序未在模拟器Xcode上运行 - iPhone app not running on simulator xcode 在XCode 9 Simulator中未调用locationManager didEnterRegion - locationManager didEnterRegion not called in XCode 9 Simulator 图像显示在 iPhone 模拟器中,但不显示在 ipad 中 - Swift - Image shows up in iPhone simulator but not ipad - Swift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM