0

IBを使用せずにiPhoneアプリで作業し、ビューベースのアプリケーションでUIViewControllerに3つのアイテムを持つUITabbarをプログラムで作成しました.1つのデリゲートメソッドを使用しました. 私はタブバービューコントローラーを持っていません。

    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 で作業する必要があります。

4

1 に答える 1

5

この警告を取り除くには、UItabBarDelegate プロトコルの必須メソッドを 1 つ実装する必要があります。

UITabBarDelegate_Protocol

必要なメソッドは次のとおりです。

– tabBar:didSelectItem:

それを実装すれば大丈夫です。

プロトコルを実装することをヘッダー ファイルで宣言することを忘れないでください。

@interface MyDelegate <UITabBarDelegate>
于 2009-11-24T09:24:40.953 に答える