0
저는 약간의 프로젝트를 설정했으며이 경우 다른 컨트롤러에서 메서드를 호출하고 싶습니다. 나는 이미 example에있는 것처럼 설정했습니다. 그러나 코드를 실행하려고했지만 메서드가 나옵니다.다른 클래스의 메서드 호출이 실패했습니다.
내가 뭘 잘못하고 있는지 아는 사람이 있습니까?
내 코드 :
Second.h :
#import <UIKit/UIKit.h>
@class First;
@interface Second : UIViewController {
}
@property (nonatomic, retain) First* vC;
@end
Second.m :
#import "Second.h"
#import "First.h"
@interface First()
@end
@implementation First
@synthesize vC;
- (IBAction)dothis:(id)sender {
NSLog(@"Hello World!");
[self.vC getThis];
}
-(void)viewDidLoad {
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(dothis:)
forControlEvents:UIControlEventTouchDown];
[button setTitle:nil forState:UIControlStateNormal];
button.frame = CGRectMake(5, 70, 270, 200);
[super viewDidLoad];
}
@end
First.h :
#import <UIKit/UIKit.h>
#import "Second.h"
@interface First: UIViewController {
//some Outlets and so on...
}
-(void)getThis;
@end
First.m : 여기
#import "First.h"
@interface First()
@end
@implementation First
-(void)getThis {
NSLog(@"You reached the end-zone!");
}
@end
당신이 내 컨트롤러 부분을 볼 수 있지만 내가 응용 프로그램을 실행하는 경우는 잘 작동합니다. 그러나 두 번째 버튼을 클릭하면 "Hello World!"가 표시됩니다. 그리고 "당신은 끝단에 도착했습니다!" 나는 alertviews와 함께 이것을 시도했다. 누군가가이 문제를 해결하는 방법을 가르쳐 주시겠습니까? 첫 번째와 두 번째 사이에는 아무런 연관이 없다고 생각하지만 왜 그럴까요?
미리 감사드립니다.
두 번째 것을 의미합니까? – MasterRazer
파일 Second.m – yuf
그런데 어디서 버튼을보기에 추가합니까? 단추를 클릭 할 수 있다고 말한 이후부터 버튼이 작동한다고했지만 단추는 표시되지 않아야합니다. – yuf