1.UITabBarController的UITabBarControllerDelegate问题
在AppDelegate 中实现UITabBarControllerDelegate 协议
@interface AppDelegate : UIResponder<UIApplicationDelegate,UITabBarControllerDelegate>
//在此方法中设置UITabBarController的代理为AppDelegate
-(BOOL) application:(UIApplication *) application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
CustomTabBarController *CustomTabBarController=(TSMainTabBarController *)self.window.rootViewController;
CustomTabBarController.delegate=self;
}//实现UITabBarController代理方法
-(void)tabBarController: (UITabBarController *) tabBarController didSelectVIewController:(UIViewController *) viewController {
NSLog(@"selected viewcontroller");
//to do your business
//例如实现不可被双击
UIViewController *vcSelected = tabBarController.selectedViewController;
if ([vcSelected isEqual:viewController]) {
return NO;
}
return YES;
}@end
2.UITabBarItem的图片问题,出现图片被拉伸显示出锯齿或图片模糊
BarItem的image需要设置一个30*30,和60*60 的png图片如30*30名称为 first.png,60*60名称为first@2X.png