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] ...
随机推荐
- SpringBoot源码解析:AOP思想以及相应的应用
spring中拦截器和过滤器都是基于AOP思想实现的,过滤器只作用于servlet,表现在请求的前后过程中:拦截器属于spring的一个组件,由spring管理, 可以作用于spring任何资源,对象 ...
- 变量改变时PHP内核做了些什么?
引言 内容来自于<Extending and Embedding PHP>- Chaper 3 - Memory Management,加上自己的理解,对php中变量的引用计数.写时复制, ...
- Nginx简易配置文件(三)(文件缓存)
server { listen 80; listen 443 ssl; server_name user.17.net userapi.17.net; access_log logs/user/acc ...
- Size Balance Tree(SBT模板整理)
/* * tree[x].left 表示以 x 为节点的左儿子 * tree[x].right 表示以 x 为节点的右儿子 * tree[x].size 表示以 x 为根的节点的个数(大小) */ s ...
- tensrflow python [defunct]
在ubuntu上面安装了GPU版本的tensorflow后,很容易碰到zombie thread 的问题,无法正常关闭tensorflow的线程,用ps aux|grep python可以看到 pyt ...
- thinkphp3.2与phpexcel带图片生成 完美案例
thinkphp3.2与phpexcel完美案例 // 导出exl public function look_down(){ $id = I('get.id'); $m = M ('offer_goo ...
- MEF 根据配置注入Service
有这样的场景 : 现在一个接口有很多种实现类,需要根据配置,来确定确定调用哪个具体的实现类.这样使得软件扩展性大大提高 在MEF可以通过ExportMetadata 来实现这样的效果. 1.现在我们建 ...
- IoC/DI基本思想的演变
---------------------------------------------------------------------------------- (1)IoC/DI的概念 IoC ...
- postgresql:pgadmin函数调试工具安装过程
通过安装第三方插件pldebugger,可实现在pgadmin客户端对函数设置断点.调试,具体过程如下: 1.下载pldebugger安装包:http://git.postgresql.org/git ...
- codevs2572 路面修整
题目描述 Description Mr. Ling打算好好修一下学校门口的那条凹凸不平的路.按照Mr. Ling的设想,修好后的路面高度应当单调上升或单调下降,也就是说,高度上升与高度下降的路段不能同 ...