iOS 工作中遇到的问题 (二)

去掉tableViewHeader的黏性


(1)
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    if (scrollView == self.tableView)
    {
        CGFloat sectionHeaderHeight = 50; //sectionHeaderHeight
        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, 0, 0);
        }
    }
}
(2)分组改成分组模式
_tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
这个时候顶部和底部都会有一段空白,加上下面代码即可
self.tableView.tableFooterView = [[UIView alloc]init];
self.tableView.tableHeaderView = [[UIView alloc]init];
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.01f;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.01f;
}

键盘管理框架IQKeyboardManager


IQKeyboardManager *manager = [IQKeyboardManager sharedManager];
manager.enable = YES;
manager.shouldResignOnTouchOutside = YES;
manager.shouldToolbarUsesTextFieldTintColor = YES;
manager.enableAutoToolbar = NO;
manager.keyboardDistanceFromTextField = 400;

tableView 滚动到指定cell


NSIndexPath  *indexPath = [NSIndexPath indexPathForRow:lastSelectRow inSection:0];  
        [self.tableView scrollToRowAtIndexPath:indexPath  
                              atScrollPosition:UITableViewScrollPositionBottom animated:YES]; 

解决崩溃:
[self.tableView setContentOffset:CGPointMake(0.0, (self.lastSelectRow ) *44.0) animated:YES];  

tableView滚动的时候退出键盘


self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;

常用的第三方库

常用的第三方库
pod 'AFNetworking'
pod 'SDWebImage'
pod 'SVProgressHUD'
pod 'XMPPFramework', :git => "https://github.com/robbiehanson/XMPPFramework.git", :branch => 'master'
pod 'Masonry'
pod 'MJExtension'
pod 'UMengAnalytics'
pod 'RDVTabBarController'
pod 'MJRefresh'
pod 'FMDB'
pod 'MBProgressHUD'
pod 'TMCache'
pod 'Reachability'
pod 'ASIHTTPRequest'
pod 'ReactiveCocoa'
pod 'ReactiveViewModel'
pod 'XXNibBridge'
pod 'FSCalendar'
pod 'JSBadgeView'
pod 'AmrVoiceConverter'
pod 'MWPhotoBrowser'
pod 'UMengUShare/UI'
pod 'UMengUShare/Social/WeChat'
pod 'UMengUShare/Social/QQ'
pod 'IQKeyboardManager', '~> 4.0.7'

自定义的粗体绘制

自定义的粗体绘制
+ (UILabel *)labelWithFrame:(CGRect)frame WithBoldFont:(UIFont*)font strokeWidth:(float)width withAttributeText:(NSString*)string
{
NSAttributedString *atbString = [[NSAttributedString alloc]
initWithString:string
attributes:[NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName,
[NSNumber numberWithFloat:width],NSStrokeWidthAttributeName, nil]];
UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];
label.attributedText = atbString;
return label;
}

oc调用js

oc调用js
#import 
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    JSContext *context = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
    weakself(self);
    //定义好JS要调用的方法, share就是调用的share方法名
    if ([self.htmlID isEqualToString:@"日程"]) {
        context[@"showDetail"] = ^(NSString *username,int month, int type,int year) {
            NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
            parameters[@"type"] = @(type);
            parameters[@"month"] = @(month);
            parameters[@"username"] = username;
            parameters[@"year"] = @(year);
            dispatch_async(dispatch_get_main_queue(), ^{
                
                CTStaisticeContentView *statisticsVc = [[CTStaisticeContentView alloc]init];
                statisticsVc.dict = parameters;
                statisticsVc.businessType = CTBusinessTypeSchedule;
                [self setHidesBottomBarWhenPushed:YES];
                [weakSelf.navigationController pushViewController:statisticsVc animated:YES];
            });
            
        };
    }
}

app国际化

app国际化
http://www.jianshu.com/p/324764985a5d

你可能感兴趣的:(iOS 工作中遇到的问题 (二))