iOS 日记 - 自适应宽度和定位

  • UILabel 绑定事件报错

**Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RightCollectionViewCell handleTap]: unrecognized selector sent to instance 0x7fc1ab73c300'

代码是这么写的:

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap)];

handleTap 改成 handleTap: 就解决了,囧。

  • UILabel 自适应宽度和定位
 // 根据文本自动设置宽度
    [_pidsLabel sizeToFit];
    [_fansLabel sizeToFit];
    
    // 重新设置定位
    CGSize size = [_pidsLabel sizeThatFits:CGSizeMake(CGRectGetWidth(_pidsLabel.frame),MAXFLOAT)];
    CGRect frame = _pidsLabel.frame;
    frame.origin.x = size.width + 80;
    _fansLabel.frame= frame;
  • 设置 APP 的图标和启动图像
    在 Assets.xcassets 中点击 AppIcon 将不同格式的 icon 拖进去即可。
    我发现用同一张图片去设置不同分辨率的 icon 图,编译时是会报错的。这里推荐一个生成多种格式 icon 的网站,
    http://makeappicon.com/,可以快速上传一张图后导出多种格式,最后右键 AppIcon 导入即可。
    设置启动图像则可以使用这货 http://www.appicon.build/
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容