目标c - UIActivityViewController定向模式 [英] Objective c - UIActivityViewController orientation mode

查看:110
本文介绍了目标c - UIActivityViewController定向模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iPhone应用程序设计仅支持纵向方向,除了一个呈现照片的视图控制器,以及支持横向模式。

My iPhone app is design to support portrait orientation only, except one view controller that present photos, and support landscape mode as well.

总的来说,我的项目支持所有方向,但每个视图控制器(照片视图控制器除外)都实现了这个方法:

So overall my project support all the orientations, but every view controller (except the photo view controller) implement the method:

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

问题:

在我的一个(仅限肖像)视图控制器中,我使用 UIActivityViewController 让用户选择通过电子邮件或短信共享内容。

In one of my (only portrait) view controller, I'm using UIActivityViewController to let the user choose sharing content through email or SMS.

当用户选择电子邮件选项时,它会自动显示ios本机电子邮件视图控制器。

When the user pick the email option, it automatically shows the ios native email view controller.

如果用户现在将设备的方向更改为横向,则电子邮件视图控制器也会更改为横向,现在如果用户点击取消/发送按钮,电子邮件控制器将获得被解雇了,现在我的所有应用都在风景中!

If the user now change the device's orientation to landscape, the email view controller also changes to landscape, now if the user tap the cancel/send button, the email controller get dismissed, and now my all app is in landscape!

有没有办法强制eamil视图控制器只能处于纵向模式?

Is there a way to force the eamil view controller to be in portrait mode only?

我知道我可以创建自己的电子邮件视图控制器和子类 UIActivity 来显示它,但不是 UIActivityViewController 在显示时不会显示默认的电子邮件图标,我真的很喜欢它显示它而不是我将提供的其他(必须是灰色)图标。

I know I can create my own email view controller and subclass UIActivity to show it, but than the UIActivityViewController won't show the default email icon when presented, and I really like it to show it and not some other (must be grey) icon that I'll provide.

推荐答案

你应该制作另一个uinavigationcontroller并从那里展示uiactivityviewcontroller。
在这段代码中_image是一个UIImage哟要分享。
BlankViewController只是你可以在IB中创建的占位符视图控制器,你也可以使它的视图背景颜色清晰,并做你想做的外观变化。

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: ^ {
        ;
    }]  ;
}];

这篇关于目标c - UIActivityViewController定向模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆