xcode - iOS SIGSEGV SEGV_ACCERR crash in layoutSubviews -


My app sometimes crashes in the LayoutSubview method This happens when the app calculates the height for the UTTableVixel The app crash sometimes works in code, not always here:

  + (CGFloat) heightForEditorialCommentData: (EditorialCommentVMData *) editorialData {EditorialCommentCell * cell = [editorialCommentCell instanceCell]; [See cell mod_data: editorial data]; [Cell layoutviewview]; Return cell.comtitlebill.framebottom + catext instance.bottom; } + (Editorial CommentCell *) Example Seven {Static Editorial Comment Calls = Example = Zero; Static transmissions_access_one talk; dispatch_once (& amp; onceToken; ^ {NSArray * ideas = [[NSBundle mainBundle] loadNibNamed: @ "editorialCommentCell" owner: 0 options: 0]; example = views [0]; instance.frame = CGRectMake (instance.contentView.frame . Orig.x, instance.contentView.frame.origin.y, [[UIScreen mainScreen] border] .size.width, instance.contentView.frame.size.height);}); Return example; }   

Here's the heap detection:

  Thread: crashed: com.apple.root.default- QoS UIKit 0x2ff92b3a - [_ UIViewAdditiveAnimationAction runActionForKey: Object: Logic:] + 56 9 1 UIKit 0x2ff92cf5 __67 - [_ UIViewAdditiveAnimationAction runActionForKey: Object: Logic] _ Block_Invoice + 408 2 Quartzcore 0x2f71e4c5 CA :: Layer :: End_change (CA :: Transaction *, Unsigned Ent, OzJecObact * ) + 96 3 Quartzcore 0x2f71f06b CA :: Layer :: set_bounds (CA :: Rect constant & amp;; bool) + 530 4 QuartzCore 0x2f71ed87 - [CALayer setBounds:] 110 5 UIKit 0x3017f84f - [_UILabelLayer setBounds:] + 58 6 QuartzCore 0x2f71fe01 - [CALay Er setFrame: + 600 7 UIKit 0x3017f7eb - [_UILabelLayer setFrame:] + 58 8 UIKit 0x2fcfc4d7 - [UIView (geometry) setframe:] + 254 9 UIKit 0x2fd09f53 - [UILabel setFrame:] + 138 CRASH-> 10 MYAPP 0x000fb611 - [ UIView (Frame) setFrameWidth:] (UIView + Frame.m: 103) 11 MyApp 0x00130c75 - [EditorialCommentCell layoutSubviews] (EditorialCommentCell.m: 139) 12 MyApp 0x001324ed + [EditorialCommentCell heightForEditorialCommentData:] (EditorialCommentCell.m: 351) 13 MyApp 0x00115733 - [EditorialCommentsViewModel applyDataFromItem: toVMItem:] (EditorialCommentsViewModel.m: 298) 14 MyApp 0x00114e73 - [EditorialCommentsViewModel vmDataFromItem:] (EditorialCommentsViewModel.m: 222) 15 MyApp 0x000fac29 - [FatherViewModel insertItemsUpdatingExisting: inVMItems:] (FatherViewModel.m: 418) 16 MyApp 0x000f9cfd __39- [FatherViewModel updateItems: Failure:] _block_invoke_3 (FatherViewModel.m: 281) 17 libdispatch.dylib 0x3a4718cb _dispatch_call_b Lock_and_release + 10 18 libdispatch.dylib 0x3a47ada3 _dispatch_root_queue_drain + 834 19 libdispatch .dylib 0x3a47bcd7 _dispatch_worker_thread3 + 94 20 libsystem_pthread.dylib 0x3a5d2e31 _pthread_wqthread + 668   

My layoutSubview code here:

  - (zero) layoutSubviews {[super layoutSubviews]; // has ever crashed CGFloat contentLeft = kTextInsets.left; BOOL is the answer = self. Editorial CommentData Reply Comment Comment! = 0; If (Accountability) {contentLeft + = kAuthorLeftInset + self.authorImageView.frameWidth; } Self.authorImageView.frameOrigin = CGPointMake (contentLeft, kContentInsets.top); Self.votesLabel.frameWidth = 200; // Sometimes crashed here [self-shaped shaped tofitt]; Self.votesLabel.frameTop = self.authorImageView.frameTop - 1.5f; Self.votesLabel.frameRight = self.contentView.bounds.size.width - kContentInsets.right; & Lt; ..... and more code here ..... & gt; }   

I think this is a memory management problem.

OK! I fixed. The method of comment about layout about Marco: "You should not call this method directly." If you want to emphasize the layout updates, call the setNeedsLayout method instead of doing the following drawing updates. " I have just changed LayoutSubviews for LayoutIfNeeded method:

  + (CGFloat) heightForEditorialCommentData: (EditorialCommentVMData *) editorialData {EditorialCommentCell * cell = [editorialCommentCell instanceCell]; [See cell mod_data: editorial data]; [Cell layoutEfnid]; Return cell.comtitlebill.framebottom + catext instance.bottom; }   

IFNeeded from Apple documentation about layout:

Use this method to force the layout of subviews before drawing. Using the view that receives the message as a root view, this method performs sub-projection that starts at root.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -