I am trying to phonegap barcode scan plugin modification.

I added UITabbar buttons.(It's not tabbar controller)

This code is not working, ı was trying many times but still given me error.This is error message with in parentheses( //tabBar.delegate = self;
// Assigning to id < UITabbarDelegate > from incompatible type CDVbcsViewController)

when I use click event button , I can't use ıt.But I need to touch click event button for using well. (didSelectItem) . How can use this plugin file with in tab bar application. ıt was give error before how can I fıx ıt. In addition, I was using uitabbar programmatically please I am waiting your help.

CDVBarcodeScanner.mm file:

UITabBar *tabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, 430, 320, 49)];

NSMutableArray *tabBarItems = [[NSMutableArray alloc] init];

UITabBarItem *tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Flight" image:[UIImage imageNamed:@"image-1.png"] tag:0];
UITabBarItem *tabBarItem1 = [[UITabBarItem alloc] initWithTitle:@"Shop" image:[UIImage imageNamed:@"mentionsIcon.png"] tag:1];

UITabBarItem *tabBarItem2 = [[UITabBarItem alloc] initWithTitle:@"Test" image:[UIImage imageNamed:@"lambicon.png"] tag:2];

UITabBarItem *tabBarItem3 = [[UITabBarItem alloc] initWithTitle:@"Other" image:[UIImage imageNamed:@"image-2.png"] tag:3];

[tabBarItems addObject:tabBarItem];
[tabBarItems addObject:tabBarItem1];
[tabBarItems addObject:tabBarItem2];
[tabBarItems addObject:tabBarItem3];

tabBar.items = tabBarItems;
tabBar.selectedItem = [tabBarItems objectAtIndex:0]; 
**//tabBar.delegate = self;**   //here you need import the protocol <UITabBarDelegate>
 // here problem ? Assigning to id <UITabbarDelegate> from incompatible type CDVbcsViewController

[overlayView addSubview:tabBar];
有帮助吗?

解决方案

your CDVbcsViewController did not conform protocol UITabbarDelegate

change this line

@interface CDVbcsViewController : UIViewController <CDVBarcodeScannerOrientationDelegate> {}

to this

@interface CDVbcsViewController : UIViewController <CDVBarcodeScannerOrientationDelegate, UITabbarDelegate> {}

and implement methods of UITabbarDelegate in CDVbcsViewController

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top