Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WatchOS warning: rejected resignFirstResponder when being removed from hierarchy

I'm getting this error in Xcode.

2018-02-26 07:13:22.326888-0500 Watch Extension[1298:2691330] [View] First responder warning: '<SPInterfacePicker: 0x14dc1740; frame = (76 0; 58 44); gestureRecognizers = <NSArray: 0x14dcd8a0>; layer = <CALayer: 0x14dc1910>>' rejected resignFirstResponder when being removed from hierarchy

My InterfaceController has 4 WkInterfacePickers and it seems like this error might be related to presenting an alert (when the user saves data), but I am not sure.

Has anyone else ever seen this?

My code:

if successSaving == true {
    DispatchQueue.main.async {
        WKInterfaceDevice.current().play(.success)
        self.showSuccessAlertWith(message: "Workout Saved, Stats Added.")
    }

    func showSuccessAlertWith(message: String){

        let action1 = WKAlertAction(title: "OK", style: .default) {
            WKInterfaceController.reloadRootPageControllers(withNames: ["InterfaceController"],
                                                                            contexts: nil,
                                                                            orientation: .vertical,
                                                                            pageIndex: 0)
        }
        presentAlert(withTitle: "Success", message: message, preferredStyle: .alert, actions: [action1])
    }
}
like image 357
GarySabo Avatar asked Feb 26 '18 12:02

GarySabo


1 Answers

I think what is happening is that WKInterfacePickers are very easy to accidentally leave in a "still editing" state, in other words if you scroll through the values then tap "Done" button (which calls reloadRootPageControllers) the system thinks the user was still in the process of editing the picker's value.

I can just ask users to be more careful (unlikely)...but I am unsure how to solve which in iOS the equivalent would be calling resignFirstResponder. Neither resignFocus nor setting isActive to false, according to my testing, prevent this message from logging.

like image 190
GarySabo Avatar answered Sep 30 '22 16:09

GarySabo