tips记录

来源:互联网 发布:如何根据数据做柱状图 编辑:程序博客网 时间:2024/06/12 21:22

1. URL转码,传中文字符串时使用,光靠stringByAddingPercentEscapesUsingEncoding是不够滴,特殊字符还需要处理。

+(NSString *)encodeURL:(NSString*)unescapedString{    NSString* escapedUrlString= (__bridge NSString*)CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)unescapedString, NULL,                                                                                            (CFStringRef)@"!*'();:@&=+$,/?%#[]", kCFStringEncodingUTF8 );        escapedUrlString = [escapedUrlString stringByAddingPercentEscapesUsingEncoding:kCFStringEncodingUTF8];    return escapedUrlString;}


2. how to make the section header of tableView not always floating on that section? 

Use group TableView.

or:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{    if ([scrollView isEqual:self.tableView]) {        CGFloat sectionHeaderHeight = sizeHeightTableHeader;        if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {            scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);        } else if (scrollView.contentOffset.y>=sectionHeaderHeight) {            scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 10.0, 0);        }    }}