我正在使用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协议的必需方法。

uitabardelegate_protocol

您可以看到所需的方法是:

– tabBar:didSelectItem:

实现它,你会没事的。

不要忘记在标题文件中声明您实现协议。

@interface MyDelegate <UITabBarDelegate>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top