다른 컨트롤러에서 하나의 뷰 컨트롤러에 정의 된 함수를 호출하고 싶습니다. I'v는 수백 가지 설정과 아무 것도 작동하지 않는 것처럼 보입니다.아이폰 용 다른 뷰 컨트롤러에서 함수 호출하기
기본 코드를 게시했으며 다른 사람들이 어떻게하는지 알려주고 싶습니다. 기본적으로 dealB 버튼을 누르면 GameViewController에서 SwitchViewController에 정의 된 MYBPress 함수를 호출하기 만하면됩니다. 어떤 도움이라도 대단히 감사하겠습니다. PS : 나는 오랜 시간 동안 코딩 만의 Obj-C
// ------- SwitchViewController.h ---------------
#import <UIKit/UIKit.h>
@class GameViewController;
@class OptionsViewController;
@interface SwitchViewController : UIViewController {
OptionsViewController *optionsViewController;
}
@property (retain, nonatomic) OptionsViewController *optionsViewController;
@property (retain, nonatomic) GameViewController *gameViewController;
-(IBAction)MyBPress:(id)sender;
@end
// -------- GameViewController.h ------------
#import <UIKit/UIKit.h>
@interface GameViewController : UIViewController {
IBOutlet UIButton *dealB;
}
@property(nonatomic,retain) IBOutlet UIButton *dealB;
- (IBAction)dealB:(id)sender;
@end
// ------- GameViewController.m
#import "GameViewController.h"
@implementation GameViewController
@synthesize dealB; // The Deal button
- (IBAction)dealB:(id)sender
{
// Here is where I want to call the MyBPress function
}
@end
감사합니다. 그것은 나쁜 디자인인가? 어쩌면 문제가 될 수 있습니다. –
안녕하세요, St3fan, 돌아가서 NsNotificationCenter를 사용하여 다시 시도하고 작동하도록했습니다. 나는 그것을 일찍 시도했지만 분명히 올바르게하지는 않았다. 귀하의 코멘트를 다시보고 저를 얻었다 :-) 내 불만은 틀에 얽매이지 않는 방법을 시도하는 저를지도하고 나는 입력 주셔서 감사합니다, 그래서 그것을 알아 냈다. –