viewController Category가 있고 해당 범주에 UILabel이 있습니다. 다른 viewController에서 레이블 제목을 설정하고 싶습니다.UIViewController에서 레이블 제목 설정
충돌이 발생했을 때.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[BaseViewController setTitleLabel:]: unrecognized selector sent to instance 0x7fcfe857a580'
어떻게하면됩니까?
편집 :
TitleLabel
여기, 카테고리에서 레이블의 UIViewController 카테고리의 코드입니다
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(0, 0, 50, 50);
[btn setImage:[UIImage imageNamed:@"Menu"] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(MenuPressed:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *leftBtn = [[UIBarButtonItem alloc]initWithCustomView:btn];
UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
btn1.frame = CGRectMake(0, 0, 70, 44);
[btn1 setTitle:@"Clickme!" forState:UIControlStateNormal];
btn1.backgroundColor = [UIColor blueColor];
UILabel *titleLabel = [UILabel new];
titleLabel.frame = CGRectMake(0, 0, 100, 44);
titleLabel.backgroundColor =[UIColor cyanColor];
UIBarButtonItem *barBtn2 = [[UIBarButtonItem alloc]initWithCustomView:btn1];
UIBarButtonItem *barTitle = [[UIBarButtonItem alloc]initWithCustomView:titleLabel];
UIBarButtonItem *flexibleItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
NSArray *barBtnArray = @[leftBtn,flexibleItem,barTitle,barBtn2];
self.navigationItem.leftBarButtonItems = barBtnArray;
titleLabel은 카테고리의 라벨로 내 편집을 확인합니다. –
문제를 파악할 수 있도록 코드를 더 게시 할 수 있습니까? – abhishekkharwar
UIViewcontroller 카테고리에서 레이블 코드를 추가했습니다. –