iOS开发的小技巧
转自简书:http://www.jianshu.com/p/50b63a221f09 http://www.jianshu.com/p/08f194e9904c
原作者:叶孤城___
self.tableView.tableFooterView = [[UIView alloc] init];
试过的都说好.
加完这句之后就变成了这样.

自定义了leftBarbuttonItem左滑返回手势失效了怎么办?
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
initWithImage:img
style:UIBarButtonItemStylePlain
target:self
action:@selector(onBack:)];
self.navigationController.interactivePopGestureRecognizer.delegate = (id<UIGestureRecognizerDelegate>)self;
ScrollView莫名其妙不能在viewController划到顶怎么办?
self.automaticallyAdjustsScrollViewInsets = NO;
键盘事件写的好烦躁,都想摔键盘了,怎么办?
- 买个结实的键盘.
- 使用IQKeyboardManager(github上可搜索),用完之后腰也不疼了,腿也不酸了.
为什么我的app老是不流畅,到底哪里出了问题?
如图

这个神器叫做:KMCGeigerCounter
快去github搬运吧.
怎么在不新建一个Cell的情况下调整separaLine的位置?
_myTableView.separatorInset = UIEdgeInsetsMake(0, 100, 0, 0);
怎么点击self.view就让键盘收起,需要添加一个tapGestures么?
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.view endEditing:YES];
}
怎么给每个ViewController设定默认的背景图片?
使用基类啊,少年.
想在代码里改在xib里添加的layoutAttributes,但是怎么用代码找啊?
像拉button一样的拉你的约束.nslayoutattribute也是可以拉线的.
怎么像safari一样滑动的时候隐藏navigationbar?
navigationController.hidesBarsOnSwipe = Yes
导航条返回键带的title太讨厌了,怎么让它消失!
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)
forBarMetrics:UIBarMetricsDefault];
CoreData用起来好烦,语法又臭又长,怎么办?
MagicalRecord
CollectionView 怎么实现tableview那种悬停的header?
CSStickyHeaderFlowLayout
原文链接:http://www.jianshu.com/p/50b63a221f09
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
能不能只用一个pan手势来代替UISwipegesture的各个方向?
- (void)pan:(UIPanGestureRecognizer *)sender
{
typedef NS_ENUM(NSUInteger, UIPanGestureRecognizerDirection) {
UIPanGestureRecognizerDirectionUndefined,
UIPanGestureRecognizerDirectionUp,
UIPanGestureRecognizerDirectionDown,
UIPanGestureRecognizerDirectionLeft,
UIPanGestureRecognizerDirectionRight
};
static UIPanGestureRecognizerDirection direction = UIPanGestureRecognizerDirectionUndefined;
switch (sender.state) {
case UIGestureRecognizerStateBegan: {
if (direction == UIPanGestureRecognizerDirectionUndefined) {
CGPoint velocity = [sender velocityInView:recognizer.view];
BOOL isVerticalGesture = fabs(velocity.y) > fabs(velocity.x);
if (isVerticalGesture) {
if (velocity.y > 0) {
direction = UIPanGestureRecognizerDirectionDown;
} else {
direction = UIPanGestureRecognizerDirectionUp;
}
}
else {
if (velocity.x > 0) {
direction = UIPanGestureRecognizerDirectionRight;
} else {
direction = UIPanGestureRecognizerDirectionLeft;
}
}
}
break;
}
case UIGestureRecognizerStateChanged: {
switch (direction) {
case UIPanGestureRecognizerDirectionUp: {
[self handleUpwardsGesture:sender];
break;
}
case UIPanGestureRecognizerDirectionDown: {
[self handleDownwardsGesture:sender];
break;
}
case UIPanGestureRecognizerDirectionLeft: {
[self handleLeftGesture:sender];
break;
}
case UIPanGestureRecognizerDirectionRight: {
[self handleRightGesture:sender];
break;
}
default: {
break;
}
}
break;
}
case UIGestureRecognizerStateEnded: {
direction = UIPanGestureRecognizerDirectionUndefined;
break;
}
default:
break;
}
}
拉伸图片的时候怎么才能让图片不变形?
UIImage *image = [[UIImage imageNamed:@"xxx"] stretchableImageWithLeftCapWidth:10 topCapHeight:10];
(刚才有人提醒这个已经deprecated了哈,现在的方法叫resizableImageWithCapInsets).
怎么播放GIF的时候这么卡,有没有好点的库?
FlipBoard出品的太适合你了。https://github.com/Flipboard/FLAnimatedImage
怎么一句话添加上拉刷新?
https://github.com/samvermette/SVPullToRefresh
[tableView addPullToRefreshWithActionHandler:^{
// prepend data to dataSource, insert cells at top of table view
// call [tableView.pullToRefreshView stopAnimating] when done
} position:SVPullToRefreshPositionBottom];
怎么把tableview里cell的小对勾的颜色改成别的颜色?
_mTableView.tintColor = [UIColor redColor];

本来我的statusbar是lightcontent的,结果用UIImagePickerController会导致我的statusbar的样式变成黑色,怎么办?
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
怎么把我的navigationbar弄成透明的而不是带模糊的效果?
[self.navigationBar setBackgroundImage:[UIImage new]
forBarMetrics:UIBarMetricsDefault];
self.navigationBar.shadowImage = [UIImage new];
self.navigationBar.translucent = YES;
怎么改变uitextfield placeholder的颜色和位置?
继承uitextfield,重写这个方法- (void) drawPlaceholderInRect:(CGRect)rect {
[[UIColor blueColor] setFill];
[self.placeholder drawInRect:rect withFont:self.font lineBreakMode:UILineBreakModeTailTruncation alignment:self.textAlignment];
原文链接:http://www.jianshu.com/p/08f194e9904c
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
iOS开发的小技巧的更多相关文章
- iOS开发的小技巧(断点打印)
iOS开发中我们会碰到这样的需求:打印沙盒目录,打印对象信息,对象信息可以通过断点查看,有时候对象属性繁多时看起来又比较麻烦. 今天学到一个比较实用的方法: 在运行时打一个断点,当程序停在这个断点后, ...
- iOS开发常用小技巧记录(持续更新)
以下问题都是自己在项目中遇到的,解决问题的方法肯定有多种,我所列举的不一定就是最好的解决办法.如有问题欢迎大家指正,补充,交流. 解决同时按两个按钮进两个view的问题.[button setExcl ...
- iOS开发一些小技巧
1.隐藏多余的tableView的cell分割线 self.tableView.tableFooterView= [[UIViewalloc]init]; 2.取消系统自带的返回字样 [[UIBarB ...
- iOS开发:小技巧积累
1.获取全局的Delegate对象,这样我们可以调用这个对象里的方法和变量: [(MyAppDelegate*)[[UIApplication sharedApplication] delegate] ...
- iOS开发:小技巧积累2
http://blog.sina.com.cn/s/articlelist_1935098904_1_1.html .获取全局的Delegate对象,这样我们可以调用这个对象里的方法和变量: [(My ...
- 转:【iOS开发每日小笔记(十一)】iOS8更新留下的“坑” NSAttributedString设置下划线 NSUnderlineStyleAttributeName 属性必须为NSNumber
http://www.bubuko.com/infodetail-382485.html 标签:des class style 代码 html 使用 问题 文件 数据 ...
- 五个goland进行go开发的小技巧
五个goland进行go开发的小技巧 本文译自5 Tips To Speed Up Golang Development With IntelliJ Or Goland 确实很实用. 1. 实现int ...
- iOS中TableView小技巧
摘要: TableView是ios开发中经经常使用到的控件,这里统一记录一下开发中遇到的经常使用小技巧,不断探索更新.也希望大家能够告诉我很多其它经常使用的小技巧啦~一起进步 1.去除多余的列表线条 ...
- iOS 知识-常用小技巧大杂烩
原文链接:http://www.jianshu.com/p/7c3ee5e67d03. 自己看的. 1,打印View所有子视图 po [[self view]recursiveDescription] ...
随机推荐
- Ceph RGW 和 niginx 配置要点
cat /etc/nginx/sites-enabled/rgw.conf server { listen 80 default; #server_name .com .com.cn .net .cn ...
- Django-跨站请求
//用户验证Tonken 在Html 中 设置一个Token {% csrf_token %} //在代码Views.py 中返回值添加 context_instance=RequestContext ...
- HTML-如何让自己的网页标题处可以显示网站的logo?
<link rel="Bookmark" href="/forum_images/ffico.png" /> <link rel=" ...
- Android开发笔记之《Window下安装Ubuntu双系统,Grub无法显示Window选项》
解决方法是: 在terminal里面输入: sudo update-grub 会找到windows的grub 重启电脑就可以了.
- Acer-宏碁电脑BOIS
进入电脑BOIS界面; 1.开机(一闪而过)注意第一屏左下角,会有进入BIOS按键提示. 2.如一开机没有进入BIOS的键值提示,取而代之的是品牌机的Logo,可参阅以下列表:不是品牌机可参阅主板设置 ...
- 正则表达式之g标志,match和 exec
1.g标志 g标志一般是与match和exec来连用,否则g标志没有太大的意义. 先来看一个带g标志的例子: var str = "tankZHang (231144) tank yi ...
- thinkphp 导出exl功能
/** * 导出数据为excel表格 *@param $data 一个二维数组,结构如同从数据库查出来的数组 *@param $title excel的第一行标题,一个数组,如果为空则没有标题 *@p ...
- 媒体查询判断ipad和iPhone各版本
/* 判断ipad */ @media only screen and (min-device-width : 768px) and (max-device-width : 1024px){ /* s ...
- V8 的 typeof null 返回 "undefined" 的 bug 是怎么回事
1997 年,IE 4.0 发布,带来的众多新特性中有一个对未来“影响深远”的 DOM API:document.all.在随后的 6 年里,IE 的市场占有率越来越高,直到 2003 年的 95%. ...
- bzoj1491 社交网络
Description 在社交网络(socialnetwork)的研究中,我们常常使用图论概念去解释一些社会现象.不妨看这样的一个问题. 在一个社交圈子里有n个人,人与人之间有不同程度的关系.我们将这 ...