標籤:
NSClassFromString用法案例
self.tabBar.items = @[//客戶
@{@"normal": @"tabbar/kehu.png",
@"selected": @"tabbar/kehu_sel.png"},
//保單
@{@"normal": @"tabbar/baodan.png",
@"selected": @"tabbar/baodan_sel.png"},
//計劃
@{@"normal": @"tabbar/jihua.png",
@"selected": @"tabbar/jihua_sel.png"},
//活動
@{@"normal": @"tabbar/huodong.png",
@"selected": @"tabbar/huodong_sel.png"},
//銷售
@{@"normal": @"tabbar/xiaoshou.png",
@"selected": @"tabbar/xiaoshou_sel.png"}
//夥伴
@{@"normal": @"tabbar/huoban.png",
@"selected": @"tabbar/huoban_sel.png"},
//設定
@{@"normal": @"tabbar/shezhi.png",
@"selected": @"tabbar/shezhi_sel.png"},
//訊息
@{@"normal": @"tabbar/message.png",
@"selected": @"tabbar/message_sel.png"}, //工具
//工具
@{@"normal": @"tabbar/tool.png",
@"selected": @"tabbar/tool_sel.png"}
];
self.viewControllers = @[//客戶
[self itemVC:@"TPLCustomerListController"],
//保單
[self itemVC:@"TPLPolicyInfoHomeController_new"],
//計劃
[self itemVC:@"TPLAgendaHomeController"],
//活動
[self itemVC:@"TPLCallonHomeController"],
//銷售
[self itemVC:@"TPLInsuplanHomeController"],
//績效
[self itemVC:@"TPLReportHomeController"],
//夥伴
[self itemVC:@"TPLPartnerHomeController"],
//設定
[self itemVC:@"TPLSettingHomeController"],
//訊息
[self itemVC:@"TPLMessageHomeController"],
//工具
[self itemVC:@"TPLToolHomeViewController"]];
- (UIViewController*)itemVC:(NSString*)className {
TPLViewController* vc = (TPLViewController*)[[NSClassFromString(className) alloc]init];
if (nil == vc) {
return nil;
}
if (![vc isKindOfClass:[TPLTabItemViewController class]]) {
[NSException raise:NSInvalidArgumentException format:@"tabitem基類必須為TPLTabItemViewController"];
}
vc.naviBarHidden = YES;
return [[TPLNavigationController alloc] initWithRootViewController:vc];
}
[轉]雜記