내 iPhone 응용 프로그램 (예 : SampleCode 프로젝트)과 하나의 샘플 코드를 통합하려고합니다. firstViewController의 샘플 코드는 MainWindow.xib에 추가되고 아래 코드에서 생성 된 viewController
에 연결됩니다. viewcontroller에서 appdelegate와 delegate의 차이점
@interface SampleCodeAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
firstViewController *viewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet firstViewController *viewController;
과의 ViewController
는 initWithCoder 인스턴스화하고 firstView 버튼이 카메라의 탭에 나타난 때 아래 코드처럼 OpenCamera 메소드를 호출 할 열릴 수있다. 내 탐색 기반 응용 프로그램 (하여 MyApplication) 내가 직접 MyApplicationAppDelegate에 추가하지 않고의 ViewController MyApplicationViewControllerA 중 하나에 SampleCode의 firstViewController를 호출 할에서//in firstViewController.mm file
- (id)initWithCoder:(NSCoder *)coder {
if (self = [super initWithCoder:coder]) {
}
[self initLocal];
return self;
}
//to open camera in SampleCode application
- (IBAction)OpenCamera {
UIApplication *app = [UIApplication sharedApplication];
SampleCodeAppDelegate* delegate = [app delegate];
UIViewController* uiViewCont = [delegate viewController];
((CCamera*)m_pCamera)->Camera(uiViewCont);
}
.
그래서 SampleCode 응용 프로그램에서 appdelegate로 작동해야하는 MyApplicationViewControllerA viewController에서 대리인을 만들고 싶습니다. 카메라를 열 수 없지만 카메라를 닫은 후에 MyApplicationViewControllerA를 제외한 다른 MyApplication보기를 열 수 없습니다. pushViewController 및 modalViewController 다른보기를 렌더링 할 수 없습니다.
위임자에 대해 혼동하지 않습니다. 그래서 AppDelegate (SampleCodeAppDelegate : NSObject <UIApplicationDelegate>
)와 다른 ViewContrller에서 선언 된 위임의 차이점을 알고 싶습니다.
[self initLocal]; 당신의 "if (self = [super init ...]) 블록 안에 있어야합니다. 수퍼 init이 실패하면 개체를 위로 설정하려고하지 않으려 고합니다. 그냥 자기를 돌려 보내라. – occulus