iPhone 横向视图屏幕截图
我正在横向模式下运行该应用程序。 我需要注意什么才能使拍摄的屏幕截图也处于横向模式。
我在 iPhone 应用程序中使用以下代码,底部有标签栏并拍摄屏幕截图,但它始终仅处于纵向模式。为什么?
UIWindow *screenWindow = [[UIApplication sharedApplication] keyWindow];
UIGraphicsBeginImageContext(screenWindow.frame.size);
[screenWindow.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
I'm running the app in landscape mode.
What care do I have to take so that the screen shot taken is also in landscape mode.
I'm using the following code in iphone app with tabbar at bottom and taking screen shot, but its always in portrait mode only. why?
UIWindow *screenWindow = [[UIApplication sharedApplication] keyWindow];
UIGraphicsBeginImageContext(screenWindow.frame.size);
[screenWindow.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我之前的回答是不正确的。我已经研究过这个问题,并且我有一个横向右屏幕截图的答案。这会将横向右侧屏幕截图正确保存到相机胶卷中。我还没有尝试过左风景。
这是另一个 stackoverflow 问题中提供的答案的变体此处。该答案的问题在于屏幕截图始终具有 UIImageOrientationUp 的 imageOrientation(只读)。因此,我们有责任了解方向是什么并适当地改变它。
我希望这有帮助。如果这适用于横向左侧,或者您得到适用于横向左侧的变体,请发布它。
My previous answer was incorrect. I have worked on this and I have an answer for a landscape right screen shot. This will save a landscape right screen shot correctly to the camera roll. I have not tried landscape left.
This is a variation on an answer provided in another stackoverflow question here. The problem with that answer is that the screen shot always has an imageOrientation (read only) of UIImageOrientationUp. Therefore it is up to us to know what the orientation was and change it appropriately.
I hope this helps. If this works on landscape left or you get a variation that works on landscape left please post it.
这是一个非常古老的线程,但目前以下是如何执行此操作,以防有人也遇到此问题。
如果你想让它向右旋转,只需将 UIImageOrientationLeft 替换为 UIImageOrientationRight
This is a really old thread, but here's how to do it currently in case anyone also has this issue.
If you want it rotated right, just replace UIImageOrientationLeft with UIImageOrientationRight