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