简体   繁体   English

在iOS7中递归-(void)layoutSubviews,但在iOS8中效果很好

[英]Recursion in - (void)layoutSubviews in iOS7 But works fine in iOS8

I am stuck in a strange issue. 我陷入一个奇怪的问题。 I have a view on which i have added autolayout. 我有一个我添加了自动布局的视图。 And inside that view there are few labels which are subclass of UILabel. 在该视图内,很少有标签是UILabel的子类。 Inside that subclass i override function - (void)layoutSubviews (the function itself is empty) Now the problem is that sometimes the - (void)layoutSubviews function called multiple times. 在该子类中,我重写了函数- (void)layoutSubviews (该函数本身为空),现在的问题是,有时- (void)layoutSubviews函数会被多次调用。

the stack trace of the same is as follows. 相同的堆栈跟踪如下。

`#1 0x00824964 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
 #2 0x01f4682b in -[NSObject performSelector:withObject:] ()
 #3 0x01c1045a in -[CALayer layoutSublayers] ()
 #4 0x01c04244 in CA::Layer::layout_if_needed(CA::Transaction*) ()
 #5 0x01c040b0 in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()
 #6 0x01b6a7fa in CA::Context::commit_transaction(CA::Transaction*) ()
 #7 0x01b6bb85 in CA::Transaction::commit() ()
 #8 0x01b6c258 in CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) ()
 #9 0x0296436e in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#10 0x029642bf in __CFRunLoopDoObservers ()
#11 0x02942254 in __CFRunLoopRun ()
#12 0x029419d3 in CFRunLoopRunSpecific ()
#13 0x029417eb in CFRunLoopRunInMode ()
#14 0x04b785ee in GSEventRunModal ()
#15 0x04b7842b in GSEventRun ()
#16 0x007b5f9b in UIApplicationMain () `

Now i am not able to understand from where it is getting called as stack trace is not showing anything. 现在我不知道从哪里调用它,因为堆栈跟踪未显示任何内容。 Can anyone help to track down the origin of the recursion here. 任何人都可以在这里帮助跟踪递归的起源。

EDIT:- It seems like the issue with autolayouts. 编辑:-似乎与自动布局的问题。 If i remove the autolayout from the view there is no more sublayout issue exists. 如果我从视图中删除自动布局,则不再存在子布局问题。 Any suggestion why this is happening. 任何建议为什么会这样。

It seems like an issue with autolayout. 似乎是自动布局问题。 Whenever i use the autolayout with aspect ratio on the view the problem appears. 每当我在视图上使用具有纵横比的自动布局时,就会出现问题。 Remove the aspect ratio from the autolayout and the issue get solved for me. 从自动布局中删除长宽比,问题就为我解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM