IOS7: UITabBarController's "more" tab design is is disturbed

I'm using UITabBarController in storyboard in my project. The project is already coded with iOS6 sdk. Now I'm working on its iOS7 compatibility. I had customized the design of "more" tab's tableview by providing my own datasource and it's working perfectly in iOS6. Strangely in iOS7 the design is disturbed. Plz see following images for more elaboration.

iOS6:

iOS7:

Finally here is the code:-

-(void)tabBarController:(UITabBarController *)tbController didSelectViewController:(UIViewController *)viewController {

    UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;

    UINavigationController *navCtr=(UINavigationController *)viewController;
    UITableView *moreTable = (UITableView *)tabBarController.moreNavigationController.topViewController.view;
    moreTable.dataSource = nil;
    if ([[navCtr.viewControllers lastObject] isKindOfClass:NSClassFromString(@"UIMoreListController")]){
        moreTableViewDataSource=[[MoreTableViewDataSource alloc] init];
        moreTable.dataSource = moreTableViewDataSource;
        [moreTable setBackgroundColor:[UIColor clearColor]];
        [moreTable setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    }

}

MoreTableViewDataSource.h

@interface MoreTableViewDataSource : NSObject <UITableViewDataSource,UITableViewDelegate>
{

}

@property  (strong, nonatomic) id<UITableViewDataSource> originalDataSource;

-(MoreTableViewDataSource *) initWithDataSource:(id<UITableViewDataSource>) dataSource;

@end

MoreTableViewDataSource.m

@implementation MoreTableViewDataSource

-(MoreTableViewDataSource *) initWithDataSource:(id<UITableViewDataSource>) dataSource
{
    self = [super init];
    if (self)
    {
        self.originalDataSource = dataSource;
    }

    return self;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return 48.0;
}
- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section
{
    return 5;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MoreTabCell *cell = (MoreTabCell*)[tableView dequeueReusableCellWithIdentifier:@"MoreTabCell"];
    if (cell==nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"MoreTabCell" owner:nil options:nil] objectAtIndex:0];
    }
    switch (indexPath.row) {
        case 0:
            cell.titleLbl.text=NSLocalizedString(@"approach", nil);
            break;
        case 1:
            cell.titleLbl.text=NSLocalizedString(@"opening_time", nil);
            break;
        case 2:
            cell.titleLbl.text=NSLocalizedString(@"weather", nil);
            break;
        case 3:
            cell.titleLbl.text=NSLocalizedString(@"ticket", nil);
            break;
        case 4:
            cell.titleLbl.text=NSLocalizedString(@"contact", nil);
            break;
        default:
            break;
    }

    cell.titleLbl.textColor=[UIColor lightBlueColor];
    [cell.titleLbl setFont:[UIFont setGothicFontBoldWithSize:14.0]];
    [cell.imgView setImage:[UIImage imageNamed:[NSString stringWithFormat:@"moreIcon%d",indexPath.row+1]]];
    cell.accessoryView = nil;
    return cell;
}
@end

Answers


After trying on my own, I've discovered that the trick is to set the delegate of the tableview to a custom one or nil. Since UIMoreListController fill out the title and other stuff in tableView:willDisplayCell:forRowAtIndexPath: method.

Hope this will help.


Instead of making your own titleLbl instance in the cell, why not simply position and style the existing titleLabel the same way? I am not sure why it is happeneing because you haven't uploaded the code for MoreTabCell, but you can try setting the titleLabel.text = nil; if you don't want to stop using titleLbl.


Need Your Help

Post Tweet using Parse framework

ios twitter parse-platform

I am having issues posting to twitter via the parse framework. I have logged in my user using this,

Refactoring needed for repetitious switch statements

c++ refactoring switch-statement

The many repetitious switch statements seems like it needs to be DRY'd. Any suggestions? (Including doing nothing!)