下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
iOS开发的22个诡异技巧结合自身的实践开发经验总结出了22个iOS开发的小技巧,以非常欢乐的语调轻松解决开发过程中所遇到的各种苦逼难题,光读着便已忍俊不禁。1.TableView不显示没内容的Cell怎么办?类似于图1,我不想让下面的那些空显示。很简单,添加“=[[UIViewalloc]init];〞试过都说好,加完这句之后就变成了图2的样子。2.自定义了leftBarbuttonItem左滑返回手势失效了怎么办?self.navigationItem.leftBarButtonItem
=
[[UIBarButtonItem
alloc]
initWithImage:imgstyle:UIBarButtonItemStylePlaintarget:selfaction:@selector(onBack:)];
self.navigationCeractivePopGestureRecognizer.delegate
=
(id<UIGestureRecognizerDelegate>)self;
3.ScrollView莫名其妙不能在viewController划到顶怎么办?self.automaticallyAdjustsScrollViewInsets
=
NO;
4.键盘事件写得好烦躁,都想摔键盘了怎么办?买个结实的键盘;使用IQKeyboardManager〔GitHub上可搜索〕,用完之后腰也不疼了,腿也不酸了。5.为什么我的App老是不流畅,到底哪里出了问题?如图:这个神器叫做:KMCGeigerCounter,快去GitHub上搬运吧。6.怎么在不新建一个Cell的情况下调整separaLine的位置?_myTableView.separatorInset
=
UIEdgeInsetsMake(0,
100,
0,
0);
7.怎么点击self.view就让键盘收起,需要添加一个tapGestures么?-
(void)touchesBegan:(NSSet
*)touches
withEvent:(UIEvent
*)event
{
[self.viewendEditing:YES];
}
8.怎么给每个ViewController设定默认的背景图片?使用基类啊,少年。9.想在代码里改在xib里添加的layoutAttributes,但该怎么用代码找?像拉Button一样地拉你的约束,nslayoutattribute也是可以拉线的。10.怎么像Safari一样滑动的时候隐藏navigationbar?navigationController.hidesBarsOnSwipe
=
Yes
11.导航条返回键带的title太讨厌了,怎么让它消失?[[UIBarButtonItem
appearance]
setBackButtonTitlePositionAdjustment:UIOffsetMake(0,
-60)
forBarMetrics:UIBarMetricsDefault];
12.CoreData用起来好烦,语法又臭又长怎么办?MagicRecord13.CollectionView怎么实现tableview那种悬停的header?CSStickyHeaderFlowLayout14.能不能只用一个pan手势来代替UISwipegesture的各个方向?-
(void)pan:(UIPanGestureRecognizer
*)sender
{
typedef
NS_ENUM(NSUInteger,
UIPanGestureRecognizerDirection)
{
UIPanGestureRecognizerDirectionUndefined,
UIPanGestureRecognizerDirectionUp,
UIPanGestureRecognizerDirectionDown,
UIPanGestureRecognizerDirectionLeft,
UIPanGestureRecognizerDirectionRight};
static
UIPanGestureRecognizerDirection
direction
=
UIPanGestureRecognizerDirectionUndefined;
switch
(sender.state)
{
caseUIGestureRecognizerStateBegan:
{
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;
}
caseUIGestureRecognizerStateChanged:
{
switch
(direction)
{
caseUIPanGestureRecognizerDirectionUp:
{
[self
handleUpwardsGesture:sender];
break;
}
caseUIPanGestureRecognizerDirectionDown:
{
[self
handleDownwardsGesture:sender];
break;
}
caseUIPanGestureRecognizerDirectionLeft:
{
[self
handleLeftGesture:sender];
break;
}
caseUIPanGestureRecognizerDirectionRight:
{
[self
handleRightGesture:sender];
break;
}
default:
{
break;
}
}
break;
}
caseUIGestureRecognizerStateEnded:
{
direction
=
UIPanGestureRecognizerDirectionUndefined;
break;
}
default:
break;
}
}
15.拉伸图片的时候怎么才能让图片不变形?方法一:UIImage
*image
=
[[UIImage
imageNamed:@"xxx"]
stretchableImageWithLeftCapWidth:10
topCapHeight:10];
注:有开发者提醒这个已经弃用,现在的方法叫resizableImageWithCapInsets。方法二,如图:16.怎么播放GIF的时候这么卡,有没有好点的库?FlipBoard出品的FLAnimatedImage太适合你了。17.怎么一句话添加上拉刷新?使用SVPullToRefresh库:[tableViewaddPullToRefreshWithActionHandler:^{
//
prepend
data
to
dataSource,
insert
cells
at
top
of
table
view//
call
[tableView.pullToRefreshViewstopAnimating]
when
done}
position:SVPullToRefreshPositionBottom];
18.怎么把tableview里Cell的小对勾颜色改成别的颜色?_mTableView.tintColor
=
[UIColorredColor];
19.本来我的statusbar是lightcontent的,结果用UIImagePickerController会导致我的statusbar的样式变成黑色,怎么办?-
(void)navigationController:(UINavigationController
*)navigationController
willShowViewController:(UIViewController
*)viewController
animated:(BOOL)animated
{
[[UIApplication
sharedApplication]
setStatusBarStyle:UIStatusBarStyleLightContent];
}
20.怎么把我的navigationbar弄成透明的而不是带模糊的效果?[self.navigationBarsetBackgroundImage:[UIImagenew]
forBarMetrics:UIBarMetricsDefault];
=
[UIImagenew];
=
YES;
21.怎么改变uitextfieldplaceholder的颜色和位置?继承uitextfield,重写这个方法:-
(void)
drawPlaceholderInRect:(CG
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 泥水平衡顶管机维修技术规程
- 人工气道的集束化管理
- 滨州市滨城区教育系统招聘考试真题2025
- 2025年中国烟草总公司辽宁省公司人员招聘考试真题
- 2025年大连瓦房店市教育系统招聘教师真题
- 2026广东交通职业技术学院招聘正高级职称退休教师笔试备考试题及答案解析
- 2026年安康市农业机械系统事业单位人员招聘考试备考试题及答案详解
- 2026年赤峰市城管协管人员招聘考试备考试题及答案详解
- 2026年巢湖市血液中心事业单位人员招聘考试备考试题及答案详解
- 2026年成都市青羊区第二人民医院医护人员招聘笔试模拟试题及答案解析
- 胸痹患者中医护理评估与干预
- 2026年4月福建厦门市思明区部分单位联合招聘非在编人员4人笔试模拟试题及答案解析
- 江苏苏豪控股集团秋招面笔试题及答案
- 24J113-1 内隔墙-轻质条板(一)
- 律师事务所内部惩戒制度
- 高中英语课堂形成性评价与听力理解能力提升教学研究课题报告
- 校园校园环境智能监测系统方案
- (2025年)资阳市安岳县辅警考试公安基础知识考试真题库及参考答案
- 涉融资性贸易案件审判白皮书(2020-2024)-上海二中院
- 制动排空气课件
- 大学生药店创业计划书
评论
0/150
提交评论