특정보기에 도구 모음을 추가하고 있지만이를 추가 할 수 있도록보기를 전달할 수 있도록 GeneralFunctions에 메서드가 있습니다. 이 버튼을 누르면iOS IBAction 전역 메서드 추가
+ (void)addCommentsBar:(UIView *)view
{
CGPoint origin = CGPointMake(0.0, view.frame.size.height - 50);
UIView *commentsView = [[UIView alloc] initWithFrame:CGRectMake(origin.x, origin.y, 320, 50)];
commentsView.backgroundColor = [PitcheroColours pitcheroBlue];
UILabel *commentsTitle = [[UILabel alloc] initWithFrame:CGRectMake(15, 2, 200, 50)];
commentsTitle.text = @"1 Comment";
commentsTitle.textColor = [UIColor whiteColor];
UIButton *tapComments = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
tapComments.backgroundColor = [UIColor clearColor];
[tapComments addTarget:self action:@selector(tapComments:) forControlEvents:UIControlEventTouchUpInside];
[commentsView addSubview:commentsTitle];
[commentsView addSubview:tapComments];
[view addSubview:commentsView];
}
그것은 tapComments를 호출
- (IBAction)tapComments:(id)sender
{
NSLog(@"Done");
}
GeneralFunctions 내부에 앉아있다
하지만 말 충돌이 :
Uncaught exception: +[GeneralFunctions tapComments:]: unrecognized selector sent to class 0x2d5b7c
는 내가 멀리에서 선택기를 호출하고 있기 때문에 알고 보기,하지만 이것을 달성하는 가장 좋은 방법은 무엇입니까?!
위대한 - 지금은 작동하는 클래스 메서드로 정의! –