Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: More tab crashes on my subclassed UITabBarController on iOS 7.1

I simply updated to iOS 7.1 and I get an unrecognized selection error for a function called "_layoutCells".

I have a simple subclass of UITabBarController.

like image 357
GenesisST Avatar asked Mar 10 '14 19:03

GenesisST


2 Answers

Note that this is a hack to avoid a bad crash until a better solution or explanation is found. I though I should share it.

Simply add the following method to your UITabBarController subclass implementation:

- (void) _layoutCells
{
    // HACK ALERT: on iOS 7.1, this method will be called from deep within the bowels of iOS.  The problem is that
    // the method is not implemented and it results in an unrecognized selected crash. So we implement it...
    //
    // What could go wrong?
}
like image 179
GenesisST Avatar answered Sep 20 '22 22:09

GenesisST


Thanks to GenesisST for giving his answer, but I know methods are called for a reason. And usually layoutCells will call layout for all subviews. While I rather wait for an answer from Apple, I like other people need to submit my app within a given timeline.

In my case, I was getting this error due to some hacks. I had replaced the UIMoreNavigationController delegate, which is an undocumented class by Apple, so I could expect errors. I am doing this hack to extend the More tab's functionality, and this error only occurs when I change the moreNavigationController tableView's delegate.

So I store their delegate, change it, then call _layoutCells to their delegate when iOS calls it on my class.

- (void)_layoutCells
{
   if([self.moreTableViewDelegate respondsToSelector:@selector(_layoutCells)]){
      [self.moreTableViewDelegate performSelector:@selector(_layoutCells)];
   }
}

I don't know if this apply's to anyone here, but just in case someone else comes to SO with my edge case.

like image 26
Michael Ozeryansky Avatar answered Sep 18 '22 22:09

Michael Ozeryansky