3

내 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에서 선언 된 위임의 차이점을 알고 싶습니다.

+1

[self initLocal]; 당신의 "if (self = [super init ...]) 블록 안에 있어야합니다. 수퍼 init이 실패하면 개체를 위로 설정하려고하지 않으려 고합니다. 그냥 자기를 돌려 보내라. – occulus

답변

2

pushViewController 및 modalViewController가 다른보기를 렌더링 할 수 없습니다.

답 : 당신은 당신이

[self performSelectorOnMainThread:@selector(showOtherView) withObject:OtherViewControllerObj waitUntilDone:YES]; 

과의 performSelectorOnMainThread

를 사용하여 주 스레드에서 작업을 수행하여 다른보기를 표시 할 필요가 있다고 생각 카메라 오버레이 화면 이후에 다른보기를 표시 할 수없는 경우 showOtherView 선택기 메소드를 사용하기 전에 navigationconroll에서 viewconroller를 푸시해야하는지 확인해야하며, 이미 푸시 된 경우에는 아래 코드와 같이 presentModalViewController를 사용하여 otherview를 표시해야한다.

-(void)showOtherView{ 

[self.navigationController pushViewController:OtherViewControllerObj animated:YES]; 

[self presentModalViewController:OtherViewControllerObj animated:YES]; 

} 

나는 이것이 작동해야한다고 생각합니다.

관련 문제