pMa*_*Man 0 iphone compiler-warnings uitabbar
我正在使用iPhone应用程序,而不是使用IB,并在基于视图的应用程序中以编程方式在UIViewController中创建了一个带有三个项目的UITabbar,我使用了一个委托方法,如果没有下面代码段中的最后一行(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];
Run Code Online (Sandbox Code Playgroud)
是否可以消除此警告?我不是Cocoa程序员,有时需要在iphone上工作.
要消除此警告,您必须实现UItabBarDelegate协议所需的一个方法.
您可以看到所需的方法是:
– tabBar:didSelectItem:
Run Code Online (Sandbox Code Playgroud)
实现这一点,你会没事的.
不要忘记在头文件中声明您实现了协议.
@interface MyDelegate <UITabBarDelegate>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4469 次 |
| 最近记录: |