Avertissement iPhone SDK: classe MyAppViewController ne met pas en œuvre le protocole « UITabbarDelegate »

StackOverflow https://stackoverflow.com/questions/1788882

Question

Im travaillant sur une application iPhone, ne pas utiliser IB et programme créé un UITabBar avec trois éléments dans un UIViewController dans une application vue, je une méthode déléguée, qui ne fonctionnera pas sans la dernière ligne dans l'extrait ci-dessous (setDelegate méthode). Je n'ai pas un 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];

Est-il possible d'éliminer cet avertissement? Je ne suis pas un programmeur de cacao, parfois besoin de travailler sur l'iPhone.

Était-ce utile?

La solution

Pour se débarrasser de cet avertissement, vous devez mettre en œuvre une méthode requise du protocole UItabBarDelegate.

UITabBarDelegate_Protocol

Vous pouvez voir que la méthode requise est:

– tabBar:didSelectItem:

et mettre en œuvre que vous serez très bien.

Ne pas oublier de déclarer dans votre fichier d'en-tête que vous implémentez le protocole.

@interface MyDelegate <UITabBarDelegate>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top