iPhone SDK警告:类MyAppViewController不能实现“ Uitabardelegate”协议
-
21-09-2019 - |
题
我正在使用iPhone应用程序,而不是使用IB,并在基于视图的应用程序中使用三个项目编程创建了一个Uitabbar,我使用了一个委托方法,该方法在下面的sippet(setDelegate方法)中无法使用最后一行。我没有TabbarviewController。
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上工作。
解决方案
要摆脱此警告,您必须实现Uitabardelegate协议的必需方法。
您可以看到所需的方法是:
– tabBar:didSelectItem:
实现它,你会没事的。
不要忘记在标题文件中声明您实现协议。
@interface MyDelegate <UITabBarDelegate>
不隶属于 StackOverflow