저는 태그 기반 응용 프로그램을 작성 중이며 각 탭 (ViewController
)에서 동일한 함수를 호출하려고합니다.클래스 메서드를 호출 할 수 없습니다.
나는 다음과 같은 방법으로 그것을 할 노력하고있어 :
#import "optionsMenu.h"
- (IBAction) optionsButton:(id)sender{
UIView *optionsView = [options showOptions:4];
NSLog(@"options view tag %d", optionsView.tag);
}
optionsMenu.h
파일 :
#import <UIKit/UIKit.h>
@interface optionsMenu : UIView
- (UIView*) showOptions: (NSInteger) tabNumber;
@end
optionsMenu.m
파일 :
@import "optionsMenu.h"
@implementation optionsMenu
- (UIView*) showOptions:(NSInteger) tabNumber{
NSLog(@"show options called");
UIView* optionsView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
optionsView.opaque = NO;
optionsView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5f];
//creating several buttons on optionsView
optionsView.tag = 100;
return optionsView;
}
@end
결과는 내가 결코이다 디버그 메시지를 표시하는 "show options"와 따라서 optionsView.tag
은 alwa입니다. ys 0
.
내가 뭘 잘못하고 있니?
나는 이것이 아마도 가장 쉽고 어리석은 질문이라는 것을 알고 있지만, 나는 그것을 스스로 해결할 수 없다.
모든 의견을 환영합니다.
나는 Objective-C라고 생각합니다. 다음 번에 적절한 언어로 질문에 태그를 답니다. –
'options'가 제대로 초기화 되었습니까? –
optionsMenu * options;로 막 선언되었습니다. –