2013-12-17 38 views
0

我在我的项目中使用UITabBarControllerstoryboard。该项目已经编码为iOS6 sdk。现在我正在研究其兼容性iOS7。我已经通过提供我自己的datasource来定制“more”标签的tableview的设计,并且它在iOS6中完美地工作。奇怪地在iOS7设计被打扰。 Plz看到下面的图像更详细阐述。IOS7:UITabBarController的“更多”选项卡设计受到干扰

iOS6的:

ios 6 screenshot

iOS7:

ios 7 screenshot

最后这里是代码: -

-(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 

回答

0

在我自己尝试后,我发现诀窍是将tableview的委托设置为自定义或nil。由于UIMoreListController填写标题和其他东西在tableView:willDisplayCell:forRowAtIndexPath:方法。

希望这会有所帮助。

+0

你是对的。尽管通过设置委托零你失去了tabbarcontroller的自动选择,但一个自定义的委托会做。非常感谢。 –

0

而是使自己的titleLbl例如在小区的,何不干脆位置和样式现有titleLabel以同样的方式?我不确定为什么会出现这种情况,因为您尚未上传MoreTabCell的代码,但如果您不想停止使用titleLbl,则可以尝试设置titleLabel.text = nil;

相关问题