DAKeyboardControl icon indicating copy to clipboard operation
DAKeyboardControl copied to clipboard

Selector issues

Open nwalter08 opened this issue 12 years ago • 11 comments
trafficstars

I am developing an iOS6 app and when I loaded a keyboard twice I would get unrecognized selector errors for inputKeyboardWillChangeFrame:

I commented out the method below and things started working.

// For the sake of 4.X compatibility [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(inputKeyboardWillChangeFrame:) name:@"UIKeyboardWillChangeFrameNotification" object:nil];

nwalter08 avatar Feb 25 '13 21:02 nwalter08

Ok so the issue I had was not the methods above but I wasn't calling [self.view removeKeyboardControl]; at the end of a view controller. Anyway to automate this in a future version?

Love this project :)

nwalter08 avatar Feb 25 '13 23:02 nwalter08

@nwalter08 did it fixed the issue calling [self.view removeKeyboardControl];? Because I having the same issue. In DAKeyboardControl.m on the addKeyboardControl:actionHandler: I putted a if ([self isKindOfClass:[UIView class]]){} around the notifications and it calm downs the crashes.

RuiAAPeres avatar Mar 19 '13 08:03 RuiAAPeres

Yes that fixed it for me.

nwalter08 avatar Mar 19 '13 17:03 nwalter08

Dude @nwalter08 you are the man! can't believe we both had the same problem. #rookiemode

kyleclegg avatar Mar 25 '13 23:03 kyleclegg

Yeah =( I'll be looking into automating this somehow. If anyone knows of a safe way of doing this without swizzling dealloc, let me know!

danielamitay avatar Mar 25 '13 23:03 danielamitay

I have a similar crash, yet I call the removeKeyboardControl method.

- (void) viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    [self.view addKeyboardPanningWithActionHandler:^(CGRect keyboardFrameInView) {}];
    [self.aTextView addKeyboardPanningWithActionHandler:^(CGRect keyboardFrameInView) {}];
}


- (void) viewWillDisappear:(BOOL)animated {
    [self.view removeKeyboardControl];
    [self.aTextView removeKeyboardControl];

    [super viewWillDisappear:animated];
}

gcerquant avatar Mar 28 '13 16:03 gcerquant

There are cases where a view can become deallocated and the viewWillDisappear: method will never be called. It's best to do it in dealloc

kylef avatar Mar 28 '13 16:03 kylef

The only case I can think of is when the app is terminated.
Otherwise, viewDidAppear: and viewWillDisappear: are always called, and will match each other.

gcerquant avatar Mar 28 '13 16:03 gcerquant

@gcerquant it's my understanding the viewDidDisappear is more reliable than viewWillDisappear. That's where I'm calling [self.view removeKeyboardControl]; and have had no problems as of yet.

kyleclegg avatar Mar 28 '13 16:03 kyleclegg

There is no more or less reliable, they are both called.
Haven't been able to look at the code (I will), but this assumption is not true.

gcerquant avatar Mar 28 '13 17:03 gcerquant

Never mind my comments. I had an old version of DAKeyboardControl (see #35).

gcerquant avatar Apr 02 '13 13:04 gcerquant