在iPhone 6设备和模拟器上破解的快照方法 [英] Snapshot methods broken on iPhone 6 device and simulator

查看:177
本文介绍了在iPhone 6设备和模拟器上破解的快照方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些未知原因,iPhone 6模拟器(和设备)上的所有屏幕截图方法似乎都存在错误。每当我调用任何截屏方法时,包括:

For some unknown reason there seems to be a possible bug with all screenshot methods on the iPhone 6 simulator (and device). Whenever I call any of the screenshot methods including:

snapshotViewAfterScreenUpdates:
resizableSnapshotViewFromRect:
drawViewHierarchyInRect:

snapshotViewAfterScreenUpdates: resizableSnapshotViewFromRect: drawViewHierarchyInRect:

将afterScreenUpdates设置为YES,屏幕闪烁。如果设置为NO,则不会出现闪烁,但我无法获得所需的功能。

with afterScreenUpdates set to YES, the screen flickers. If set to NO, then no flicker occurs, but I am unable to get the functionality that I need.

这些方法适用于所有iOS7.1和iOS8除了iPhone 6和6 +之外的其他模拟器。

These methods work fine with both iOS7.1 and iOS8 in all other simulators except for the iPhone 6 and 6+.

奇怪的是,如果我使用故事板开始一个全新的项目并尝试类似的代码,我无法重现闪烁。我使用非故事板项目附加了闪烁的GIF:

Strangely enough, if I start a brand new project using storyboards and try similar code I can't reproduce the flicker. I have attached a gif of the flicker using my non-storyboard project:

这是非常简单的视图控制器:

And here is the very simple view controller:

    @implementation TestSnapshotController

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Snap" style:UIBarButtonItemStylePlain target:self action:@selector(_snap)];

    self.blueView = [UIView new];
    self.blueView.backgroundColor = [UIColor blueColor];
    self.blueView.frame = CGRectMake(100.0f, 100.0f, 100.0f, 100.0f);
    [self.view addSubview:self.blueView];
}

- (void)_snap
{
    [self.blueView snapshotViewAfterScreenUpdates:YES];
}

@end

这是我的AppDelegate以防万一:

And here is my AppDelegate just in case:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    TestSnapshotController *testVC = [TestSnapshotController new];
    UINavigationController *rootNavVC = [[UINavigationController alloc] initWithRootViewController:testVC];

    self.window.rootViewController = rootNavVC;
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];

    return YES;
}

任何帮助都将不胜感激!

Any help would be greatly appreciated!

推荐答案

我们在运行以下代码时遇到同样的问题:

We are seeing this same issue when running the following code:

[window drawViewHierarchyInRect:window.bounds afterScreenUpdates:YES];

我们到目前为止找到的唯一解决方案是确保应用程序具有适合的启动图像iPhone 6和6+然后我们不再闪烁。

The only solution that we have found so far is to make sure that the application has launch images sized for the iPhone 6 and 6+ and then we no longer are getting the flickering.

这篇关于在iPhone 6设备和模拟器上破解的快照方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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