我想將UIView作爲BottomNavBar的子類(下面的代碼)。 我收到以下錯誤子類化uiView>無法識別的選擇器
'-[UIView setCenterImage:]: unrecognized selector sent to instance 0x14dc5050'
設置幾個斷點的地方我想誤差來源於此行
self.centerImage=[UIImage imageNamed:@"icon_OK.png"]; //I used it just for testing it should be as follows:
self.centerImage=centerIcon;
BottomNavBar.m
- (id)initWithFrame:(CGRect)frame centerIcon:(UIImage*)centerIcon withFrame:(CGRect)centerFrame
{
self = [super initWithFrame:frame];
if (self) {
self=[[UIView alloc]initWithFrame:frame];
[self setBackgroundColor:UA_NAV_BAR_COLOR];
//--------------------------------------------------
self.centerImage=[UIImage imageNamed:@"icon_OK.png"]; //for testing
//self.centerImage=centerIcon; >>this is the one that should be used
self.centerImageView=[[UIImageView alloc]initWithFrame:centerFrame];
self.centerImageView.image=self.centerImage;
[self addSubview:self.centerImageView];
}
return self;
}
cropPhoto.m(以顯示該類別的對象...)
CGRect bottomBarFrame = CGRectMake(0, self.view.frame.size.height-UA_BOTTOM_BAR_HEIGHT, self.view.frame.size.width, UA_BOTTOM_BAR_HEIGHT);
NSLog(@"UA_icon_ok: %@", UA_ICON_OK);
self.bottomNavBar = [[BottomNavBar alloc] initWithFrame:bottomBarFrame centerIcon:UA_ICON_OK withFrame:CGRectMake(0, 0, 90, 45)];
[self.view addSubview:self.bottomNavBar];
任何人都可以幫助解決這裏發生的問題嗎?
setCenterImage - >在底部導航欄的.h文件中添加此方法 – santhu