奇葩2: storyboard中使用AutoLayout,设置Label居中,但不起作用
来源:互联网 发布:网络实时监控 app 编辑:程序博客网 时间:2024/06/05 15:30
具体描述:
UICollectionViewCell中的所有控件,设置了居中,但是实际效果都是偏左一点。
之前都是没有问题的。 不知道改动了什么。其他页面没有问题。UICollectionView中新添加一个cell,也是偏左。
左图,storyboard中的设计, 右图,模拟器中实际跑出来的结果。
原因:
不明
解决办法:
storyboard中设置了UICollectionView的CellSize为260,336。
代码中动态改变了cellSize的值
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) { //平板横屏大小 return CGSizeMake(310,372); }else{ //平板竖屏大小 return CGSizeMake(350,420); } } else { //手机大小 return CGSizeMake(260,336); }}
经过多次尝试发现,代码中和storyboard中,CellSize的宽度设置不一致,效果就不一样。
最终是设置260的时候,正好是居中的。 大于260,偏左,小于260偏右。原因不明。
0 0
- 奇葩2: storyboard中使用AutoLayout,设置Label居中,但不起作用
- Storyboard 中使用 Autolayout
- storyBoard中为label设置边框
- 使用storyboard设置label的自适应高度
- StoryBoard 中使用AutoLayout实现Animation效果
- Autolayout的使用--居中的设置
- 【iOS开发-120】在storyboard中如何使用Size Classes,其实就是设置多套AutoLayout
- asp.net中设置label.text居中
- iOS8中storyboard中autolayout和size class的使用
- iOS:iOS8开发storyboard中autolayout和size class的使用详解 (2)
- xib自定义UIView 在Storyboard中使用AutoLayout
- 在storyboard中使用AutoLayout遇到各种坑
- 使用AutoLayout布局2个button居中
- StoryBoard中Autolayout约束UIScrollView
- storyboard中的uiscrollview,使用autolayout
- storyboard 控件设置autolayout没起作用
- StoryBoard设置Cell中的Label自适应高度
- iOS Storyboard、xib中的UIScrollView使用autolayout
- 常用的CSS代码片段
- setting.xml 详解
- 行列转换
- JSP----session
- Maven系列--pom.xml 配置详解
- 奇葩2: storyboard中使用AutoLayout,设置Label居中,但不起作用
- JDBC 编程步骤
- opencv 函数
- 【Android UI设计与开发】第11期:顶部标题栏(二)ActionBar实现Tab选项卡和下拉导航列表
- 进程地址空间分布
- java.lang.OutOfMemoryError: PermGen space及其解决方法
- 集群中几种session同步解决方案的比较(转)
- android Binder详解(3)
- 一个可以选中当前菜单后高亮显示的导航条