iOS开发常用技巧-常见问题篇

1.需要在某些情况下在外部设置自定义cell中imageView的image时,如果直接设置imageView.image的话,可能会出现UI布局走样。这时可以在cell的头文件里声明一个UIImage,在UIImage的set方法中设置imageView的image,外部访问公开的UIImage来达到设置cell中imageView的image的目的。

2.比较两个UIImage的图片是否相同,可以先把图片转换成NSData,然后比较。

NSData *headerImageData = UIImagePNGRepresentation(weakSelf.headerImage);
        NSData *defaultImageData = UIImagePNGRepresentation(DefaultHeaderImage);
        if ([headerImageData isEqualToData:defaultImageData]) {
            NSLog(@"Same");
            return;
        }

3.修改TableView侧边搜索栏背景及字体颜色

//点击后背景颜色
table.sectionIndexTrackingBackgroundColor = [UIColor clearColor];
//背景颜色
table.sectionIndexBackgroundColor = [UIColor clearColor];
//文字颜色
table.sectionIndexColor = [UIColor colorWithHexString:@"#656565"];

4.修改状态栏颜色
参考文章
首先在info.plist里加入UIViewControllerBasedStatusBarAppearance,并设置为NO,然后添加代码

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
}

5.修改AFN的超时时间

[manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];
manager.requestSerializer.timeoutInterval = 3.f;[manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];

6.弹出键盘遮挡TextField的解决办法

7.iOS App图标和启动页图片大小

8.同一个view下多个collectionView不要共用一个UICollectionViewFlowLayout,否则会出现indexpath取值错误

9.如果用registerClass注册collectionView的cell,那么cell应该重写initWithFrame函数。如果用registerClass注册tableView的cell,那么cell应该重写initWithStyle:withReuseableCellIdentifier函数。

10.网络状态判断

11.iOS10相关问题

12iOS URL转码

13.时间戳与NSDate互转

14.Pop动画简介

15.iOS 动画简介

16.WKWebView简介

17.39个SwiftUI开源库

18.iOS键盘处理 使用说明

19.获取当前APP版本号

20.获取当前APP在AppStore中的版本号

21.iOS App跳转到AppStore和跳转到AppStore评价页面

22.iOSUIWebView清除缓存

23.iOSWKWebView清除缓存

24.macos 10.12 装cocoapods

猜你喜欢

转载自blog.csdn.net/koptop/article/details/52733975