前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ios 开发常用技巧

ios 开发常用技巧

作者头像
honey缘木鱼
发布2018-06-13 16:31:25
5640
发布2018-06-13 16:31:25
举报
文章被收录于专栏:娱乐心理测试娱乐心理测试

1.TableView不显示没内容的Cell怎么办?

self.tableView.tableFooterView = [[UIView alloc] init];

2.自定义了leftBarbuttonItem左滑返回手势失效了怎么办?

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]

initWithImage:img

style:UIBarButtonItemStylePlain

target:self

action:@selector(onBack:)];

self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;

(最好在父控制器里写)

3.ScrollView莫名其妙不能在viewController划到顶怎么办?

self.automaticallyAdjustsScrollViewInsets = NO;

4.键盘事件写的好烦躁,都想摔键盘了,怎么办?

使用IQKeyboardManager(github上可搜索)

5.1、禁止手机睡眠

[UIApplication sharedApplication].idleTimerDisabled = YES;

6.隐藏某行cell

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

// 如果是你需要隐藏的那一行,返回高度为0

if(indexPath.row == YouWantToHideRow)

return 0;

return 44;

}// 然后再你需要隐藏cell的时候调用

[self.tableView beginUpdates];

[self.tableView endUpdates];

7.禁用button高亮

button.adjustsImageWhenHighlighted = NO;

或者在创建的时候

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

8.画水印

// 画水印

- (void) setImage:(UIImage *)image withWaterMark:(UIImage *)mark inRect:(CGRect)rect

{

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 4.0)

{

UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 0.0);

}

//原图

[image drawInRect:self.bounds];

//水印图

[mark drawInRect:rect];

UIImage *newPic = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

self.image = newPic;

}

9.cell去除选中效果

cell.selectionStyle = UITableViewCellSelectionStyleNone;

10.cell点按效果

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

[tableView deselectRowAtIndexPath:indexPath animated:YES];

}

11.更多的小技巧在www.cocoachina.com/ios/20170626/19616.html


本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017.06.30 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档