做项目的细节整理点

作者: 离离离离 | 来源:发表于2016-07-18 15:29 被阅读83次

1.计算Lable文字分行的行高

-(CGFloat)heightWithLable:(NSString*)txtStr andFont:(CGFloat)font andWidth:(CGFloat)width
{    return [txtStr boundingRectWithSize:CGSizeMake(width, 10000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:font]} context:nil].size.height;
}

2.TableVIewCell以及动态高度总结

http://mobile.51cto.com/iphone-481498.htm
http://www.jianshu.com/p/c7f97863b12c

3.自定义tableView的XIB

cell=[[[NSBundle mainBundle]loadNibNamed:@"TableCell" owner:nil options:nil]lastObject];

4.超强alertview alertcontroller的封装

AlertView
http://www.cocoachina.com/ios/20141126/10320.html

5.超好用教程:安装COCOPOD

http://www.jianshu.com/p/0dfe9e404910
http://blog.csdn.net/showhilllee/article/details/38398119

6.pch文件配置:

$(SRCROOT)/Public.pch

7.创建一个btn为新的barbutton

 UIBarButtonItem *left=[[UIBarButtonItem alloc]initWithCustomView:backBtn];   
//赋值给左边
[self.navigationItem setLeftBarButtonItem:left];

8.代码块self弱引用

__weak typeof(self) weakSelf = self;

9.去除UITableView单元格默认的分割线,拖动没有线条显示

 tableView.separatorStyle = NO;

10.去除UITableView单元格取消选择状态

cell.selectionStyle = UITableViewCellSelectionStyleNone;

11.调整section头滑动--tableView(头部粘合性)

http://blog.sina.com.cn/s/blog_801997310102vpa1.html

12.xib拖拉-自定义的view

-(instancetype)init
{    if (self=[super init])    
    {  self=[[NSBundle mainBundle] loadNibNamed:@"FooterSectionV" owner:self options:nil][0];   
   }
    return self;
}

注意:如果要规定view的大小,必须要写上self.frame=frame。不然view的尺寸会不固定

13.价格删除线

NSUInteger length = [good_TabCell.good_OriPriceLa.text length];
NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:good_TabCell.good_OriPriceLa.text];
[attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, length)];
[attri addAttribute:NSStrikethroughColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0, length)];[good_TabCell.good_OriPriceLa setAttributedText:attri];
ceilf(height);//向上取整

14.第三方登录白名单

友盟http://dev.umeng.com/social/ios/ios9
shareSdk:http://wiki.mob.com/快速集成指南/
http://www.360doc.com/content/15/0121/14/20919452_442560039.shtml

15.单元格和列表逆序存放

hotCell.textLabel.text=self.oldArr[self.oldArr.count-1-indexPath.row];

16.把搜索记录数组记录存在缓存里面

NSUserDefaults *userDefaults=[NSUserDefaults standardUserDefaults];
NSMutableArray *searchArr=[userDefaults objectForKey:@"searchTxtArr"];
if (!searchArr||searchArr.count==0)
{
        searchArr=[NSMutableArray new];
        [userDefaults setObject:searchArr forKey:@"searchTxtArr"];
}
searchArr=searchArr.mutableCopy;
//把数据写入
[searchArr addObject:searchTerm];
self.oldArr=searchArr;
[userDefaults setObject:self.oldArr forKey:@"searchTxtArr"];
[userDefaults synchronize];
[self.searchTabV reloadData];

删除列表数据的方法
先删除缓存再删除列表,然后再更新

16.我也不知道这些网址做什么,有空去看看

http://www.aiuxian.com/article/p-3121607.html
https://yq.aliyun.com/articles/31365

http://www.faceye.net/search/104560.html
http://www.cocoachina.com/ios/20150126/11011.html

17.设置了按钮的selected的选择状态,必须要设置这个才有效

sender.selected=!sender.selected;

18.

https://github.com/Tim9Liu9/TimLiu-iOS#%E4%BE%A7%E6%BB%91%E4%B8%8E%E5%8F%B3%E6%BB%91%E8%BF%94%E5%9B%9E%E6%89%8B%E5%8A%BF

19.xib拖拉按钮时,自定义按钮,不然点击时会有蓝色一小点

选择和普通状态时候,按钮样式要设置成custom

20.直接选中第几个标签栏

self.navigationController.tabBarController.selectedIndex=2;

21.倒计时代码

倒计时http://www.zuimoban.com/jiaocheng/ios/2016/0115/3663.html

22.

第三方http://www.jianshu.com/p/3625796aaf98

23.汉字转拼音代码

汉字转拼音:
//汉字转拼音  
  if ([city length])  
  {        
          NSMutableString *ms = [[NSMutableString alloc] initWithString:city];       
          if (CFStringTransform((__bridge CFMutableStringRef)ms, 0, kCFStringTransformMandarinLatin, NO))
           {           
                   NSLog(@"pinyin: %@", ms);       
           }       
          if (CFStringTransform((__bridge CFMutableStringRef)ms, 0, kCFStringTransformStripDiacritics, NO)) 
          {         
                    NSLog(@"pinyin: %@", ms);          
                    NSArray *arr=[ms componentsSeparatedByString:@" "];           
                    ms=[NSMutableString new];          
                    for (NSString *str in arr)           
                   {               
                         [ms appendString:str];          
                   }            
                     city=ms;       
          } 
    }

24.修改Tableview的分割线长度和底部多余的分割线

//修改分割线长度        
UIEdgeInsets edgeInset = _searchTabV.separatorInset;        
_searchTabV.separatorInset = UIEdgeInsetsMake(edgeInset.top, 0, edgeInset.bottom, edgeInset.right);        
//修改没有cell的分割线取消        
_searchTabV.separatorStyle=UITableViewCellSeparatorStyleSingleLine; 
_searchTabV.tableFooterView = [[UIView alloc] init];

25.自定义导航栏按钮会把自带的左滑手势给隐藏了,需要如下设置则可以使用

//开启iOS7的滑动返回效果
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)])
{    
     self.navigationController.interactivePopGestureRecognizer.delegate = nil; 
}

26.btn上的字左对齐和边距

btn文字左对齐
button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;  
button.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);

相关文章

网友评论

    本文标题:做项目的细节整理点

    本文链接:https://www.haomeiwen.com/subject/obnqjttx.html