问题与[UIView的(几何)_applyISEngineLayoutValues​​]在iOS8上而不是iOS7的角度重新进入 [英] issue with reentering of view with [UIView(Geometry) _applyISEngineLayoutValues] in iOS8 but not iOS7

查看:397
本文介绍了问题与[UIView的(几何)_applyISEngineLayoutValues​​]在iOS8上而不是iOS7的角度重新进入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在上被别人启动一个应用程序时的iOS 5是当前我相信开始。大部分的UI是产生code和不使用自动布局和约束明确。然而,也有一些(后来加入)自包含UI这是由应用程序更高级别的观点包含的元素,在笔尖(厦门国际银行)定义的内部使用的自动布局(以code产生的,而不是使用自动布局) 。

I am working on an app that was started by others and I believe started when iOS 5 was current. Most of the UI is code generated and does not use auto layout and constraints explicitly. However, there are some (later added) self contained UI elements, defined in a nib(xib) that use auto layout internally, which are contained by higher level views from the app (generated in code and not using auto layout).

code的一个部分产生这些自之一的合成图像包含的元素,动画的形象出来,然后交换图像的实际UI元素视图。各种这些自给自足的UI元素(都基于相同的基类,但用自己的笔尖(厦门国际银行))可以传递到这个程序,显示他们作为解释。他们中的大多数只是罚款iOS中7和iOS 8,出动画在屏幕上。

One section of code generates a composite image of one of these self contained elements, animates that image out, and then swaps the image for the actual UI element view. A variety of these self contained UI elements (all based on the same base class but with their own nibs (xib)) can be passed into this routine that displays them as explained. Most of them work just fine in iOS 7 and iOS 8, animating out onto the screen.

然而,一个特定的用户界面元素,只iOS8上,动画正确,但动画完成部分完成后,它重置它的位置,使得其中心位于0,0。在iOS中7这一次正常工作。

However, one specific UI element, on iOS8 only, animates out correctly, but after the completion part of the animation is finished, it resets its position such that its center is at 0,0. This one works fine in iOS 7.

我比较了code和坯的正常工作与这一个元素,但没有看到任何的创建和违规UI元素的内部结构做不同的元素。

I have compared the code and nibs for the elements that work fine with this one element but don't see anything done differently in the creation and internal composition of the offending UI element.

我添加了一个关键路径观测到的@中心视图中的关键路径,所以我可以看到谁是造成这种重新定心,这似乎是在自动排料系统code - 没有我的code是在回溯。

I added a key path observer to the view for the @"center" key path so I could see who was causing this re-centering and it appears to be in auto layout system code -- none of my code is in the backtrace.


#0  0x002ed826 in -[MyFundsManager observeValueForKeyPath:ofObject:change:context:] at /Users/me/Dev/MyApp/iosapp/MyApp/MyFundsManager.m:158
#1  0x24b30372 in NSKeyValueNotifyObserver ()
#2  0x24b3001e in NSKeyValueDidChange ()
#3  0x24b1c840 in -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] ()
#4  0x27463738 in -[UIView(Geometry) _applyISEngineLayoutValues] ()
#5  0x273898ee in -[UIView(Geometry) _resizeWithOldSuperviewSize:] ()
#6  0x23dff6ee in __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke ()
#7  0x23dff5ea in -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] ()
#8  0x2737a54a in -[UIView(Geometry) resizeSubviewsWithOldSize:] ()
#9  0x2746389c in -[UIView(AdditionalLayoutSupport) _is_layout] ()
#10 0x2760dbd4 in -[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] ()
#11 0x27372b36 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#12 0x26d9accc in -[CALayer layoutSublayers] ()
#13 0x26d966b4 in CA::Layer::layout_if_needed(CA::Transaction*) ()
#14 0x26d9653c in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()
#15 0x26d95f20 in CA::Context::commit_transaction(CA::Transaction*) ()
#16 0x26d95d24 in CA::Transaction::commit() ()
#17 0x2736afc4 in _afterCACommitHandler ()
#18 0x23e9e5cc in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#19 0x23e9bc8a in __CFRunLoopDoObservers ()
#20 0x23e9c092 in __CFRunLoopRun ()
#21 0x23dea620 in CFRunLoopRunSpecific ()
#22 0x23dea432 in CFRunLoopRunInMode ()
#23 0x2b1980a8 in GSEventRunModal ()
#24 0x273d4808 in UIApplicationMain ()
#25 0x0003e3fc in main at /Users/me/Dev/MyApp/iosapp/MyApp/main.m:17

下面是code,做的自包含的UI元素,这是一个与它的内部组成一个笔尖和经销商布局实现了一个自包含的视图控制器和视图通过。该动画

Here is the code that does the animating of the passed in self contained UI element, which is a self contained view controller and view which is implemented with a nib and auto layout for its internal composition.

在inView是在传递应该包含用户界面元素(父视图的UI元素)的观点。在支付页是自包含UI元素视图控制器。

The "inView" is the view passed in that should contain the UI element (parent view to the UI element). The "payPage" is the view controller for the self contained UI element.


    的CGRect payRect = CGRectMake(windowSize.width / 2 - pageSize.width / 2,windowSize.height / 2 - pageSize.height / 2 - 偏移,pageSize.width,pageSize.height);
    UIGraphicsBeginImageContext(payPage.view.bounds.size);
    [[[[付款网页视图]层] renderInContext:UIGraphicsGetCurrentContext()];
    // [付款网页视图] drawViewHierarchyInRect:payPage.view.bounds afterScreenUpdates:YES];这个// iOS8上的问题 - 跳跃和闪烁
    *的UIImage = compositeImage UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

CGRect payRect = CGRectMake(windowSize.width/2 - pageSize.width/2, windowSize.height/2 - pageSize.height/2 - offset, pageSize.width, pageSize.height); UIGraphicsBeginImageContext(payPage.view.bounds.size); [[[payPage view] layer] renderInContext:UIGraphicsGetCurrentContext()]; //[[payPage view] drawViewHierarchyInRect:payPage.view.bounds afterScreenUpdates:YES];// iOS8 issues with this -- jumps and flickers UIImage *compositeImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();

UIImageView *compositeImageView = [[UIImageView alloc] initWithImage:compositeImage];

[[payPage view] setAlpha:0.0f];

UIViewController *parentVC = [self visibleVC];

_parentVC = parentVC;

UIView *inView = [(MyStandardViewController *)parentVC localView];

CGRect middleRect = CGRectZero;

if (nil == fromView)
{
    middleRect.origin = [[[UIApplication sharedApplication] keyWindow] center];
}
else
{
    middleRect.origin = [[fromView superview] convertPoint:[fromView center] toView:inView];
}
[compositeImageView setFrame:middleRect];

_blockingView = [[UIView alloc] initWithFrame:[inView frame]];
[_blockingView setAlpha:0.0f];
[_blockingView setBackgroundColor:BLOCKINGVIEWBACKGROUNDCOLOR];

[inView addSubview:_blockingView];

[inView addSubview:compositeImageView];

[UIView animateWithDuration:2.25f animations:^{

        [compositeImageView setFrame:payRect];
        [_blockingView setAlpha:1.0f];
        }
    completion:^(BOOL finished) {

        [inView addSubview:[payPage view]];
        if (nil != parentVC)
           {
             [parentVC addChildViewController:payPage];
              }

        [[payPage view] setFrame:payRect];            
        [[payPage view] setAlpha:1.0f];           
        [compositeImageView removeFromSuperview];        
        }
    ];

我不知道该怎么做。我曾尝试 -setTranslatesAutoresizingMaskIntoConstraints:在各个地方既YES和NO的父视图。我已经看过加时不这样做,并没有看到任何明显的差别自我包含的UI元素(视图控制器)。我不知道,因为code,做它是在自动布局和应用程序并没有真正自觉地使用自动版面,但里面具体的自包含的视图控制器上这是什么接近的途径。

I am not sure what to do. I have tried -setTranslatesAutoresizingMaskIntoConstraints: on the parent view in various places with both YES and NO. I have looked at self contained UI elements (view controllers) that don't do this when added and don't see any obvious differences. I am not sure what avenue to be approaching on this since the code that does it is in auto layout and the app does not really consciously use auto layout except inside specific self contained view controllers.

推荐答案

在我的情况,我有一个隐藏 setTranslatesAutoresizingMaskIntoConstraints:在我的子视图执行NO 的我错过了。消除这种使一切工作的方式应。

In my case, I had a "hidden" setTranslatesAutoresizingMaskIntoConstraints:NO in the implementation of my subview that I had missed. Eliminating this made everything work the way it should.

这篇关于问题与[UIView的(几何)_applyISEngineLayoutValues​​]在iOS8上而不是iOS7的角度重新进入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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