correct to use rac_prepareForReuseSignal

417 Views Asked by At

when keyboard show, i hope cell was scroll up, so i would like to observer if some textview was become first responder

so:

    cell.textView.rac_signalForSelector("becomeFirstResponder")
        .takeUntil(cell.rac_prepareForReuseSignal)
        .flattenMap { (x) -> RACStream! in
            return NSNotificationCenter.defaultCenter().rac_addObserverForName(UIKeyboardDidShowNotification, object: nil)
    }
        .subscribeNext { [weak self](notify) -> Void in
            __logln("be4")
    }

however when i click at cell.textView, the "be4" was output 4 times
then when i leave the pop the viewcontroller and push back,
and click at a cell.textView again, the output was 8 times

it seem that, the singal was not clear when cell was reuse

1

There are 1 best solutions below

0
On

I get the answer, it was because the SoGou input method, it send three time UIKeyboardDidShowNotification notify ....