UITableViewCell selection Storyboard segue is slow - double tapping works though

前端 未结 2 547
清歌不尽
清歌不尽 2020-12-10 11:26

I have a UITableViewController in a Storyboard. I have the selection of my UITableViewCell prototype trigger a segue to present another controller. The presentation itself i

2条回答
  •  余生分开走
    2020-12-10 12:00

    Carlos Vela is right, the bug is accouring only when UITableViewCell selection is none and only on real device. Waking up CFRunLoop after selection solves the problem and this led me to this "universal" workaround (which is a category on UITableViewCell).

    UPDATE: it works perfectly under iOS7 but under iOS8 it brokes transparent UITableViewCell background (it will be white).

    #import 
    
    @implementation UITableViewCell (WYDoubleTapFix)
    
    + (void)load
    {
        Method original, swizzled;
    
        original = class_getInstanceMethod([UITableViewCell class], @selector(setSelected:animated:));
        swizzled = class_getInstanceMethod([UITableViewCell class], @selector(mySetSelected:animated:));
        method_exchangeImplementations(original, swizzled);
    }
    
    - (void)mySetSelected:(BOOL)selected animated:(BOOL)animated
    {
        [self mySetSelected:selected animated:animated];
        CFRunLoopWakeUp(CFRunLoopGetCurrent());
    }
    
    @end
    

提交回复
热议问题