转自简书: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;

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

  1. 买个结实的键盘.
  2. 使用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;
} }

拉伸图片的时候怎么才能让图片不变形?

  1. UIImage *image = [[UIImage imageNamed:@"xxx"] stretchableImageWithLeftCapWidth:10 topCapHeight:10];
    (刚才有人提醒这个已经deprecated了哈,现在的方法叫resizableImageWithCapInsets).

  2.  

怎么播放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开发的小技巧的更多相关文章

  1. iOS开发的小技巧(断点打印)

    iOS开发中我们会碰到这样的需求:打印沙盒目录,打印对象信息,对象信息可以通过断点查看,有时候对象属性繁多时看起来又比较麻烦. 今天学到一个比较实用的方法: 在运行时打一个断点,当程序停在这个断点后, ...

  2. iOS开发常用小技巧记录(持续更新)

    以下问题都是自己在项目中遇到的,解决问题的方法肯定有多种,我所列举的不一定就是最好的解决办法.如有问题欢迎大家指正,补充,交流. 解决同时按两个按钮进两个view的问题.[button setExcl ...

  3. iOS开发一些小技巧

    1.隐藏多余的tableView的cell分割线 self.tableView.tableFooterView= [[UIViewalloc]init]; 2.取消系统自带的返回字样 [[UIBarB ...

  4. iOS开发:小技巧积累

    1.获取全局的Delegate对象,这样我们可以调用这个对象里的方法和变量: [(MyAppDelegate*)[[UIApplication sharedApplication] delegate] ...

  5. iOS开发:小技巧积累2

    http://blog.sina.com.cn/s/articlelist_1935098904_1_1.html .获取全局的Delegate对象,这样我们可以调用这个对象里的方法和变量: [(My ...

  6. 转:【iOS开发每日小笔记(十一)】iOS8更新留下的“坑” NSAttributedString设置下划线 NSUnderlineStyleAttributeName 属性必须为NSNumber

    http://www.bubuko.com/infodetail-382485.html 标签:des   class   style   代码   html   使用   问题   文件   数据 ...

  7. 五个goland进行go开发的小技巧

    五个goland进行go开发的小技巧 本文译自5 Tips To Speed Up Golang Development With IntelliJ Or Goland 确实很实用. 1. 实现int ...

  8. iOS中TableView小技巧

    摘要: TableView是ios开发中经经常使用到的控件,这里统一记录一下开发中遇到的经常使用小技巧,不断探索更新.也希望大家能够告诉我很多其它经常使用的小技巧啦~一起进步 1.去除多余的列表线条 ...

  9. iOS 知识-常用小技巧大杂烩

    原文链接:http://www.jianshu.com/p/7c3ee5e67d03. 自己看的. 1,打印View所有子视图 po [[self view]recursiveDescription] ...

随机推荐

  1. SignalR主动通知订阅者示例

    html代码: <script src="~/Scripts/jquery.signalR-2.2.0.min.js"></script> <scri ...

  2. caffe中accuracy和loss用python从log日志里面获取

    import re import pylab as pl import numpy as np if __name__=="__main__": accuracys=[] loss ...

  3. DialogFragment is gone after returning back from another activity

    基本情景如下: 在DialogFragment中单击一个按钮跳转到another Activity做一些逻辑处理,然后将返回的结果回显到该DialogFragment上. 处理逻辑是: 在Dialog ...

  4. Hibernate的session缓存和对象的四种状态

    一.session缓存 说session缓存就得说到JAVA对象的生命周期,当没有任何引用指向一个对象时,对象则可以被gc回收,也就是生命周期结束了 而hibernate获取一个对象后,会将对象存入s ...

  5. JQuery事件之鼠标事件

    鼠标事件是在用户移动鼠标光标或者使用任意鼠标键点击时触发的. ():click事件:click事件于用户在元素敲击鼠标左键,并在相同元素上松开左键时触发. $('p').click(function( ...

  6. 5Hibernate入门----青软S2SH(笔记)

    这里有个问题,就是这本书第五章的示例代码中的hibernate的jar包有问题,各种找不到类,把lib下的包后换成第六章里的包就好了. 换成5.1的就好了,而且如果只是简单使用hibernate的话, ...

  7. SSH搭建

    1.首先在lib中导入ssh需要的jar包: 如图: 2.其次配置web.xml (在WEB-INF目录下) <?xml version="1.0" encoding=&qu ...

  8. golang笔记——map

    通过 new 创建的引用类型对象是不完整创建,比如 map,它仅分配了字典类型本身所需的内存(指针包装),而没有分配键值存储内存,也没有初始化散列桶等内部属性,因此无法工作,如下代码就是错误的: p ...

  9. service和serviceImpl的选择

    同行中,有些同行公司的代码风格是service层=service接口+serviceImpl实现类: 而有的同行公司的代码风格是service层=service类: 为什么不一样呢? 以前没想过这个问 ...

  10. HTML5+CSS3 - 代码简写篇

    有话先说:我是一只菜鸟,还是一只刚步入前端这个领域的小菜年,在不断的进阶,理解最深刻的还是代码,既爱又恨却不知如何去感悟. background属性简写: background-position属性组 ...