The label “Cancel” from modal segue in Apple Watch showing wrong text - “abbrechen”

China☆狼群 提交于 2019-12-06 00:07:36

问题


When my WKInterfaceController poped up by pressing a menuItem (which was settup by "self.addMenuItem in mainScreen"), the title on the poped WKInterfaceController shows "abbrechen" instead of "Cancel". Anyone know how to fix it to make it showing "Cancel"? Or like where did I probably make a mistake?

//MainScreen.swift
func setContextItems(directToEnabled: Bool) {
        self.clearAllMenuItems()
        self.addMenuItem(with: WKMenuItemIcon.decline, title: "direct", action: #selector(MainScreen.freePressed))
}

Clues:

  • It happens only on my Apple Watch device (WatchOS 3.1). When it runs on the simulator(Xcode 8.2.1, iPhone 7 plus), it works fine showing "Cancel".
  • My Langauge & Region are both English. "Langauge & Region" in my Watch App and my iPhone setting are both English for language and Australian for region.
  • "abbrechen" is "abort" or "cancel" in German.
  • There's a related question on SO.
  • Maybe I changed some plist setting for langauge somewhere.
  • I searched my project, and I can not find keywords like "german", "abbrechen"
  • I did used "#if (TARGET_OS_IOS || TARGET_IPHONE_SIMULATOR)", but there's nothing related.

I guess I might change a plist somewhere that change the locale/laguage only on the Apple Watch. Or maybe it's a rare WatchOS bug. Anyone saw similar problem before ?


回答1:


Check if you are overriding the language settings when installing over Xcode. This can be done using the scheme editor in Xcode:

  • Click the target in the Run destination menu and choose Edit Scheme.
  • On the right, select Options.
  • Check Application Language setting

More information on Testing Specific Languages and Regions (@developer.apple.com)




回答2:


I am a bit confused by you code? You are giving it the title 'direct' but expecting a title of 'Cancel'?

Should you not be doing:

    self.clearAllMenuItems()
    self.addMenuItem(withImageNamed: "imageFileForDirectButton", title: "Direct", action: #selector(TheController.menuDirectButtonPressedFunction))
    self.addMenuItem(with: WKMenuItemIcon.decline, title: "Cancel", action: #selector(TheController.menuCancelButtonPressedFunction))



回答3:


Have you tried overriding the title?

override func awake(withContext context: Any?)
{
    self.setTitle("Cancel")       
    super.awake(withContext: context)
}

override func willActivate()
{
    self.setTitle("Cancel")
}


来源:https://stackoverflow.com/questions/41457733/the-label-cancel-from-modal-segue-in-apple-watch-showing-wrong-text-abbrech

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!