Xcode6.01 Bug encountered in storyboard to Uicollectionviewcell AutoLayout

Source: Internet
Author: User

Using SB to AutoLayout the content of Uicollectionviewcell, found a Xcode6.01 bug, that is, when you are bound to the Uicollectioncell, the real label on the simulator is centered, But the real machine is really not the center, then Google a bit, and found the problem, this is because using the iOS8 SDK compiled projects run in iOS 7 caused the Contentview size has not changed, one of the solutions: is to re-layoutsubviews the method in your definition of the Uicollectionviewcell subclass, each time the cell layout is condemned, See if Self.contentView.frame.size and self.frame.size are consistent as Contentview are automatically laid out, and then re-modify the Uicollectionviewcell frame.

-(void) layoutsubviews{    [Super Layoutsubviews];     = cgsizeequaltosize (self.frame.size, self.contentView.frame.size);     if ( ! contentviewisautoresized) {        = self.contentView.frame;         = self.frame.size;         = contentviewframe;    }    NSLog (@ "%@", Nsstringfromcgrect (Self.contentView.frame));}

If you do not have a custom cell class, you can also

-(Uicollectionviewcell *) CollectionView: (Uicollectionview *) CV Cellforitematindexpath: (Nsindexpath *) Indexpath Add the following code

[Cell.contentview setFrame:cell.bounds]; [Cell.contentview setautoresizingmask:uiviewautoresizingflexibleheight| Uiviewautoresizingflexiblewidth];

Another way is to Xcode6.1.1 select Storyboard and then select Show in file Inspecter to change ios8.0 and later to ios7.1 can also be resolved;

Also attached stackoverflow the original solution: http://stackoverflow.com/questions/24750158/ Autoresizing-issue-of-uicollectionviewcell-contentviews-frame-in-storyboard-pro

Xcode6.01 Bug encountered in storyboard to Uicollectionviewcell AutoLayout

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.