iPhone SDK警告:类MyAppViewController未实现';UITabbarDelegate';协议
我在一个iPhone应用程序上工作,不使用IB,在一个基于视图的应用程序中,通过编程在UIViewController中创建了一个包含三项的UIAbbar,我使用了一个委托方法,如果没有下面代码段中的最后一行(setDelegate方法),它将无法工作。我没有tabbarviewcontrolleriPhone SDK警告:类MyAppViewController未实现';UITabbarDelegate';协议,iphone,compiler-warnings,uitabbar,Iphone,Compiler Warnings,Uitabbar,我在一个iPhone应用程序上工作,不使用IB,在一个基于视图的应用程序中,通过编程在UIViewController中创建了一个包含三项的UIAbbar,我使用了一个委托方法,如果没有下面代码段中的最后一行(setDelegate方法),它将无法工作。我没有tabbarviewcontroller UITabBar *tabbar = [[UITabBar alloc] initWithFrame:CGRectMake(0, YMAX-60, XMAX, 40)]; NSMu
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];
是否可以消除此警告?我不是Cocoa程序员,有时需要在iphone上工作。要消除此警告,您必须实现UItabBarDelegate协议的一个必需方法
@interface MyDelegate <UITabBarDelegate>
您可以看到所需的方法是:
– tabBar:didSelectItem:
实施这一点,你会没事的
不要忘记在头文件中声明您实现了该协议
@interface MyDelegate <UITabBarDelegate>
@接口MyDelegate
要消除此警告,您必须实现UItabBarDelegate协议的一个必需方法
@interface MyDelegate <UITabBarDelegate>
您可以看到所需的方法是:
– tabBar:didSelectItem:
实施这一点,你会没事的
不要忘记在头文件中声明您实现了该协议
@interface MyDelegate <UITabBarDelegate>
@接口MyDelegate
我已经实现了tabBar:didSelectItem方法,并在头文件中声明了该方法。你能告诉我你回复的最后一行吗?我不明白。谢谢……太好了……这是唯一的问题,你的帮助得15分!:)非常感谢:)最后一件事,如果声明实现了委托,则不需要在头文件中使用消息签名,但这样做没有害处。我已经实现了tabBar:didSelectItem方法,并且也在头文件中声明了。你能告诉我你回复的最后一行吗?我不明白。谢谢……太好了……这是唯一的问题,你的帮助得15分!:)非常感谢:)最后一件事,如果声明实现了委托,则不需要在头文件中使用消息签名,但拥有它并没有害处。