Objective c - UIActivityViewController orientation mode

只愿长相守 提交于 2019-12-01 21:12:32

You should make another uinavigationcontroller and present uiactivityviewcontroller from there. In this code _image is a UIImage yo wan to share. BlankViewController is just place holder viewcontroller you can create in IB you can also make it's view's background colour to clear and do what ever appearance changes you want to do.

__weak  CurrentViewController  *weakSelf    =   self  ;

UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[_image] applicationActivities:nil]   ;
UIViewController        *viewC  =   [[UIViewController alloc] initWithNibName:@"BlankViewController" bundle:nil] ;
UINavigationController  *navC   =   [[UINavigationController alloc] initWithRootViewController:viewC]  ;
activityViewController.completionHandler = ^(NSString *activityType, BOOL completed)
{
    [weakSelf dismissViewControllerAnimated:NO completion: ^ {
        ;    // Your completion handler
    }]  ;
};
[self presentViewController:navC animated:NO completion: ^ {
    [navC presentViewController:activityViewController animated:YES completion: ^ {
        ;
    }]  ;
}];

i had similar problems in the app i am currently developing. i ended up overwriting more of the rotation methods to make sure my own viewcontroller stays in portrait.

that's what worked for me (IOS5+):

- (BOOL) shouldAutorotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}

- (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

if you are pre ios5 or that's not working for you have a look at: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html

hope you get it to work. :)

May be u should try

- (void)viewWillAppear:(BOOL)animated
{
   [self shouldAutorotateToInterfaceOrientation: UIInterfaceOrientationLandscapeRight];
   [super viewWillAppear:animated];
}

on your view?

Couldn't found a solution to this problem, so I ended up implementing my own email UIActivity subclass...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!