0
我在一个iPhone应用程序上工作,没有使用IB,并且在基于视图的应用程序中以UIViewController的三个项目以编程方式创建了一个UITabbar,我使用了一个委托方法,如果没有下面代码片段中的最后一行(setDelegate方法),那将无法工作。我没有一个tabbarviewcontroller。iPhone SDK警告:类MyAppViewController没有实现'UITabbarDelegate'协议
UITabBar *tabbar = [[UITabBar alloc] initWithFrame:CGRectMake(0, YMAX-60, XMAX, 40)];
NSMutableArray *items = [[NSMutableArray alloc] initWithCapacity:3];
[items addObject:[[[UITabBarItem alloc] initWithTitle:@"One" image:[UIImage imageNamed:@"img04.png"] tag:0] autorelease]];
[items addObject:[[[UITabBarItem alloc] initWithTitle:@"Two" image:[UIImage imageNamed:@"img.png"] tag:1] autorelease]];
[items addObject:[[[UITabBarItem alloc] initWithTitle:@"Three" image:[UIImage imageNamed:@"img-01.png"] tag:2] autorelease]];
tabbar.items = items;
tabbar.alpha = 1.0;
tabbar.userInteractionEnabled = YES;
[tabbar setBackgroundColor:[UIColor blueColor]];
[tabbar setDelegate:self];
是否可以消除此警告?我不是可可程序员,有时需要在iphone上工作。
我已经实现了tabBar:didSelectItem方法,并在头文件中声明。你能告诉我关于你答复的最后一行吗?我没有得到它。谢谢.. – pMan 2009-11-24 09:45:13
我已经用示例更新了答案 – 2009-11-24 09:55:46
完美...这是唯一的问题,并为您的帮助15点! :) – pMan 2009-11-24 09:58:50