tips记录

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);
        }
    }
}



你可能感兴趣的:(tips记录)