2013-06-06 1 views
-5

UI를 열지 않고 기본 응용 프로그램을 열려고하는 응용 프로그램이 있습니다. Activityviewcontroller.ios에서 UIActivityViewController를 표시하지 않고 앱을 직접 여는 방법은 무엇입니까?

버튼을 클릭하면 기본 앱을 열려고합니다.

버튼 클릭으로 앱의 URL을 설정했지만 여전히 활동보기 컨트롤러를 표시하고 있습니다.

UIActivityViewController를 피하는 방법?

미리 감사드립니다.

편집

나는 버튼의 클릭에 인스 타 그램에 이미지를 공유하고 있습니다.

여기 내 코드입니다. 이 UIActivityView에서 열리는 스크린에 도시 된 바와 같이

NSURL *instagramURL = [NSURL URLWithString:@"instagram://"]; 

       if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) 
       { 

        CGRect rect = CGRectMake(0 ,0 , 0, 0); 
        UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0); 
        [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 

        UIGraphicsEndImageContext(); 
        NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
        NSString* documentsDirectory = [paths objectAtIndex:0]; 

        imagename=[NSString stringWithFormat:@"FameFace.ig"]; 
        NSString* fullPathToFile = [documentsDirectory stringByAppendingPathComponent:imagename]; 
        ////NSLog(@"%@",fullPathToFile); 

        igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", fullPathToFile]]; 

        self.dic.UTI = @"com.instagram.photo"; 
        self.dic = [self setupControllerWithURL:igImageHookFile usingDelegate:self]; 
        self.dic=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile]; 
    self.dic.annotation = [NSDictionary dictionaryWithObject:@"Image" forKey:@"InstagramCaption"]; 
    [self.dic presentOpenInMenuFromRect: rect inView: self.view animated: YES ]; 

enter image description here

.

버튼을 클릭하면 즉석에서 ActivityViewController를 표시하지 않고 기본 앱으로 이동 할 수 있습니까?

+0

코드를 입력하십시오. –

+0

코드 없음, 도움 말 없음. –

답변

2

당신은 [[UIApplication sharedApplication] openURL:appURL]

그것은 귀하의 경우에는 다음과 같이 보일 것이다 사용하여 응용 프로그램을 열 수 있습니다

NSURL *instagramURL = [NSURL URLWithString:@"instagram://"]; 

if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) 
{ 
    NSURL * openInstagramURL = nil; 
    //TODO: construct your proper instagram URL here. 
    [[UIApplication sharedApplication] openURL:openInstagramURL]; 
} 

중요한 것은 당신이 제대로 URL을 구성해야한다는 것입니다 같은 수신 응용 프로그램이, 이 경우 Instagram은 올바른 동작을 수행합니다.

+0

NSURL * openInstagramURL = nil; [[UIApplication sharedApplication] openURL : openInstagramURL]; 이 두 줄을 추가했지만 여전히 ActivityView를 보여줍니다. – Manthan

+0

먼저 instagram에 적절한 URL을 만들어야합니다. nil은 분명히 작동하지 않습니다. 그리고 두 번째로'UIDocumentInteractionController'를 사용하여 코드를 삭제해야합니다. –