这是一篇相当于,我开发过程中的一篇笔记吧。可能比较杂乱,是我的第一篇文章。
1.应用三方地图软件的时候:地图功能显示网格
出现这个的原因,可能是你的地图apikey有问题,
2. button 文字对其
Button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;//左对齐(UIControlContentHorizontalAlignment、CenterUIControlContentHorizontalAlignmentFill、UIControlContentHorizontalAlignmentRight)
Button.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom;//底部对其(UIControlContentVerticalAlignmentCenter、UIControlContentVerticalAlignmentFill、UIControlContentVerticalAlignmentTop)
3设置button 上图片,文字的位置
button.imageEdgeInsets = UIEdgeInsetsMake(5,13,21,button.titleLabel.bounds.size.width);//设置image在button上的位置(上top,左left,下bottom,右right)这里可以写负值,对上写-5,那么image就象上移动5个像素
button.titleEdgeInsets = UIEdgeInsetsMake(71, -button.titleLabel.bounds.size.width-50, 0, 0);//设置title在button上的位置(上top,左left,下bottom,右right)
4.向上取整 ceilf()
5断点续传主要方法
/ /. 操作
AFHTTPRequestOperation *op = [[AFHTTPRequestOperation alloc] initWithRequest:request];
_downloadOperation = op;
// 下载
// 指定文件保存路径,将文件保存在沙盒中
NSArray docs = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString path = [docs[0] stringByAppendingPathComponent:@“download.zip”];
op.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:NO];
// 设置下载进程代码块
bytesRead 当前第一次读取的字节数(100k)
totalBytesRead 已经下载的字节数(4.9M)
totalBytesExpectedToRead 文件总大小(5M)
[op setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
// 设置进度条百分比
CGFloat precent = (CGFloat)totalBytesRead / totalBytesExpectedToRead;
NSLog(@"%f", precent);
_progressView.progress = precent;
}];
6//主动退出程序
- (void)exitApplication {
[UIView beginAnimations:@"exitApplication" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
// [UIView setAnimationTransition:UIViewAnimationCurveEaseOut forView:self.view.window cache:NO];
[UIView setAnimationTransition:UIViewAnimationCurveEaseOut forView:self.window cache:NO];
[UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];
//self.view.window.bounds = CGRectMake(0, 0, 0, 0);
self.window.bounds = CGRectMake(0, 0, 0, 0);
[UIView commitAnimations];
}
- (void)animationFinished:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
if ([animationID compare:@"exitApplication"] == 0) {
exit(0);
}
}
8设置tableViewCell间的分割线的颜色
[theTableView setSeparatorColor:[UIColor xxxx ]];
9.SDWebImage 清除图片缓存
指定的
[[SDImageCache sharedImageCache] removeImageForKey:url];
[[SDImageCache sharedImageCache] removeImageForKey:url fromDisk:YES];
全部
[[SDImageCache sharedImageCache] clearDisk];
[[SDImageCache sharedImageCache] clearMemory];
忽略缓存,每次都直接下载方法
UIImage *selectImage = [UIImage imageNamed:[NSString stringWithFormat:@"bottom_profile_active"]];
self.tabBarController.tabBar.selectedItem.selectedImage = [selectImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
10.tableView正在滚动停止滚动
CGPoint offset = self.tableView.contentOffset;
(self.tableView.contentOffset.y > 0) ? offset.y-- : offset.y++;
[self.tableView setContentOffset:offset animated:NO];
另外://在willDisplayCell里面处理数据能优化tableview的滑动流畅性
//获取所有cell 的方法
NSArray*array = [self.tableView visibleCells];
11.修改tabbar
设置文字颜色
[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],
设置位子字体
NSForegroundColorAttributeName, [UIFont systemFontOfSize:18], NSFontAttributeName, nil]];
取到对应nav
UIViewController *vc2 = self.tabBarController.viewControllers[2];
设置对应图片
UIImage * homenormalImage = [[UIImage imageNamed:@"bottom_tv_bg"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImage * homeselectImage = [[UIImage imageNamed:@"bottom_tv_bg"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
vc2.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"" image:homenormalImage selectedImage:homeselectImage];
设置文字位置
[self.navigationController.tabBarItem setTitlePositionAdjustment:UIOffsetMake(0, -5)];
设置图片位置
self.navigationController.tabBarItem.imageInsets = UIEdgeInsetsMake(-2.5, 0, 2.5, 0);
12.GCD并列请求:
dispatch_group_t serviceGroup = dispatch_group_create();
// Start the first service
dispatch_group_enter(serviceGroup);
[self.configService startWithCompletion:^(ConfigResponse *results, NSError* error){
// Do something with the results
configError = error;
dispatch_group_leave(serviceGroup);
}];
// Start the second service
dispatch_group_enter(serviceGroup);
[self.preferenceService startWithCompletion:^(PreferenceResponse *results, NSError* error){
// Do something with the results
preferenceError = error;
dispatch_group_leave(serviceGroup);
}];
dispatch_group_notify(serviceGroup,dispatch_get_main_queue(),^{
// Assess any errors
NSError *overallError = nil;
if (configError || preferenceError)
{
// Either make a new error or assign one of them to the overall error
overallError = configError ?: preferenceError;
}
// Now call the final completion block
completion(overallError);
});
13.防止 timer 阻塞
[[NSRunLoop currentRunLoop] addTimer:_animationTimer forMode:UITrackingRunLoopMode];
14.masonry 等分控件
/**
* 多个控件固定间隔的等间隔排列,变化的是控件的长度或者宽度值
*
* @param axisType 轴线方向
* @param fixedSpacing 间隔大小
* @param leadSpacing 头部间隔
* @param tailSpacing 尾部间隔
*/
- (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType
withFixedSpacing:(CGFloat)fixedSpacing l
eadSpacing:(CGFloat)leadSpacing
tailSpacing:(CGFloat)tailSpacing;
/**
* 多个固定大小的控件的等间隔排列,变化的是间隔的空隙
*
* @param axisType 轴线方向
* @param fixedItemLength 每个控件的固定长度或者宽度值
* @param leadSpacing 头部间隔
* @param tailSpacing 尾部间隔
*/
- (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType
withFixedItemLength:(CGFloat)fixedItemLength
leadSpacing:(CGFloat)leadSpacing
tailSpacing:(CGFloat)tailSpacing;
15.数据遍历快速,高效方法
//enumerateObjectsUsingBlock 类似于for,但是比for更快
[array enumerateObjectsUsingBlock:^(MyCell * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[obj cellOffset];
}];
16.runtime 或者属性
// 获取对象里的属性列表
objc_property_t * properties = class_copyPropertyList([instance
class], &outCount);
for (i = 0; i < outCount; i++) {
objc_property_t property =properties[i];
// 属性名转成字符串
NSString *propertyName = [[NSString alloc] initWithCString:property_getName(property) encoding:NSUTF8StringEncoding];
// 判断该属性是否存在
if ([propertyName isEqualToString:verifyPropertyName]) {
free(properties);
return YES;
}
}
free(properties);
17.如何获取app 网页JS代码 command+, 进入偏好设置, 高级打开菜单栏,然后safafi 开发-simulate-选择你想要的。
18.一些干货推荐
(1)图片大全
http://findicons.com/
http://www.easyicon.net/
(2)大牛blog
博客地址 RSS地址
OneV's Den http://onevcat.com/atom.xml
破船之家 http://beyondvincent.com/atom.xml
NSHipster http://nshipster.cn/feed.xml
Limboy 无网不剩 http://feeds.feedburner.com/lzyy
唐巧的技术博客 http://blog.devtang.com/atom.xml
Lex Tang http://lexrus.com/feed.xml
念茜的博客 http://nianxi.net/feed.xml
Xcode Dev http://blog.xcodev.com/atom.xml
Ted's Homepage http://wufawei.com/feed
txx's blog http://blog.t-xx.me/atom.xml
Kevin Blog http://zhowkev.in/rss
阿毛的蛋疼地 http://www.xiangwangfeng.com/atom.xml
亚庆的 Blog http://billwang1990.github.io/atom.xml
Nonomori http://nonomori.farbox.com/feed
言无不尽 http://tang3w.com/atom.xml
Wonderffee's Blog http://wonderffee.github.io/atom.xml
I'm TualatriX http://imtx.me/feed/latest/
Cocoabit http://blog.cocoabit.com/atom.xml
nixzhu on scriptogr.am http://nixzhu.me/feed
不会开机的男孩 http://studentdeng.github.io/atom.xml
Nico http://blog.inico.me/atom.xml
阿峰的技术窝窝 http://hufeng825.github.io/atom.xml
answer_huang http://answerhuang.duapp.com/index.php/feed/
webfrogs http://blog.nswebfrog.com/feed/
代码手工艺人 http://joeyio.com/atom.xml
Lancy's Blog http://gracelancy.com/atom.xml
I'm Allen http://www.imallen.com/atom.xml
Travis' Blog http://imi.im/feed
王中周的技术博客 http://wangzz.github.io/atom.xml
会写代码的猪 http://gaosboy.com/feed/atom/
克伟的博客 http://feed.cnblogs.com/blog/u/23857/rss
摇滚诗人 http://feed.cnblogs.com/blog/u/35410/rss
Luke's Homepage http://geeklu.com/feed/
萧宸宇 http://iiiyu.com/atom.xml
Yuan博客 http://www.heyuan110.com/?feed=rss2
Shining IO http://shiningio.com/atom.xml
YIFEIYANG--易飞扬的博客 http://www.yifeiyang.net/feed
KooFrank's Blog http://koofrank.com/rss
hello it works http://helloitworks.com/feed
码农人生 http://msching.github.io/atom.xml
玉令天下的Blog http://yulingtianxia.com/atom.xml
不掏蜂窝的熊 http://www.hotobear.com/?feed=rss2
猫·仁波切 https://andelf.github.io/atom.xml
煲仔饭 http://ivoryxiong.org/feed.xml
里脊串的开发随笔 http://adad184.com/atom.xml
Chun Tips http://chun.tips/atom.xml
Why's blog - 汪海的实验室 http://blog.callmewhy.com/atom.xml
Kenshin Cui's Blog http://www.cnblogs.com/kenshincui/rss
技术哥的博客 http://suenblog.duapp.com/rss/
(3)很多优秀的第三方库
http://blog.csdn.net/yipanbo/article/details/40047735
(4)swift 学习
http://wiki.jikexueyuan.com/project/swift/
http://www.ioscookies.com 三方插件
19 tableViewCell
UITableViewCell分割线左边部分缺少一些的解决方法
-(void)viewDidLayoutSubviews {
if ([self.mytableview respondsToSelector:@selector(setSeparatorInset:)]) {
[self.mytableview setSeparatorInset:UIEdgeInsetsZero];
}
if ([self.mytableview respondsToSelector:@selector(setLayoutMargins:)]) {
[self.mytableview setLayoutMargins:UIEdgeInsetsZero];
}
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPat{
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
[cell setSeparatorInset:UIEdgeInsetsZero];
}
}
20 UIButton怎样去掉高亮透明效果
- (void)setHighlighted:(BOOL)highlighted{
}
self.btn_loginNow.adjustsImageWhenDisabled = NO;
self.btn_loginNow.adjustsImageWhenHighlighted = NO;
21 报错clang
这个错误一定是有重复的类,或者属性 比如使用了 const