和任何新的iOS版本一样,有着一堆堆的新技巧和修改需要处理.有些我并不会立即遇到,所以这篇文章并不是一套完整技巧汇总.只是分享一些我碰巧遇到的问题.

如果你有任何更多的发现,可以发Twitter或者email给我.我将免费一起汇入这篇文章.

Stealing The Blur

不幸的是,苹果并没有给你在views上直接使用模糊效果的方法.不过有一些聪明人采取修改UIToolbar的layer来做到iOS模糊. iOS-blur

你如果是想使用黑色风格的模糊,设置这个toolbar的barstyle为UIBarStyleBlack.

Tinting The Navbar

设置导航条的颜色,但是没有效果?原来还有另外一个设置色调的属性叫:'barTintColor'.

  self.navigationController.navigationBar.barTintColor = [UIColor blueColor];

Nil Those Delegates

在 iOS7 上你需要在你controllers销毁之前,将 delegates and datasources 设置成 nil.否则你会有很多让人讨厌的' 'message sent to deallocated instance''异常

  - (void)dealloc
{
self.tableView.delegate = nil;
self.tableView.dataSource = nil;
}

Hide The Status Bar

你是不是不喜欢透明的状态栏浮在内容的上面?是的,我也不喜欢.

标准的说法是不要在做任何诡计.

  [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade]

在Info.plist里面设置UIViewControllerBasedStatusBarAppearance 为 YES,然后添加这个到你的controller里面

  - (BOOL)prefersStatusBarHidden
{
return YES;
}

Changing The Status Bar Style Per Controller

在Info.plist里面设置UIViewControllerBasedStatusBarAppearance 为 YES,然后覆写:

  - (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}

Custom Back Button And Swipe Back

我发现唯一好的办法重写back按钮就是设置leftBarButtonItem,但是这样swipe 的手势又有问题了.幸运的是有一个非常简单的办法来修复

  self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
initWithImage:img
style:UIBarButtonItemStylePlain
target:self
action:@selector(onBack:)];
self.navigationController.interactivePopGestureRecognizer.delegate = (id<UIGestureRecognizerDelegate>)self;

Full Screen Content Transition

当内容全屏展示的时候(比如一个展开的视频),并且这时用户旋转方向,然后再关闭.你常常就会得到一个异常.这个情况就需要拿出preferredInterfaceOrientationForPresentation方法了.

     - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}

Checking For iOS 7

这不是什么新鲜方法.但是如果你只想在iOS7下执行可以这样写

     if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
...
}

判断iOS7以下的话可以这样:

 NSUInteger DeviceSystemMajorVersion();

 NSUInteger DeviceSystemMajorVersion() {

         static NSUInteger _deviceSystemMajorVersion = -;

         static dispatch_once_t onceToken;

         dispatch_once(&onceToken, ^{
_deviceSystemMajorVersion = [[[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."] objectAtIndex:] intValue];
});
return _deviceSystemMajorVersion;
} #define IOS_VERSION_LOW_7 (DeviceSystemMajorVersion() < 7)

My Scroll View Is Moving!

iOS7 默认偏移你的scrollview 64px(20px的状态栏,44px的导航栏)

不过你依然可以禁用这个

   self.automaticallyAdjustsScrollViewInsets = NO;

CocoaPods在iOS5有问题的

可以点击这个链接

iOS7开发技巧的更多相关文章

  1. 移动 Web 开发技巧之(后续)

    昨天的<移动 Web 开发技巧>的这篇文章,大家反响不错,因为这些问题在大家日常写移动端的页面时经常遇到的.所以那个文章还是超级实用的,那么我们今天继续来分享一下移动端的web开发技巧吧, ...

  2. 移动端web开发技巧(转)

    原文链接:http://liujinkai.com/2015/06/06/mobile-web-skill/ 移动端web开发技巧 这是一个最好的时代,因为我们站在潮流中:但也是一个最坏的时代,因为我 ...

  3. SQL开发技巧(二)

    本系列文章旨在收集在开发过程中遇到的一些常用的SQL语句,然后整理归档,本系列文章基于SQLServer系列,且版本为SQLServer2005及以上-- 文章系列目录 SQL开发技巧(一) SQL开 ...

  4. DelphiXE2 DataSnap开发技巧收集

    DelphiXE2 DataSnap开发技巧收集 作者:  2012-08-07 09:12:52     分类:Delphi     标签: 作为DelphiXE2 DataSnap开发的私家锦囊, ...

  5. delphi XE5下安卓开发技巧

    delphi XE5下安卓开发技巧 一.手机快捷方式显示中文名称 project->options->Version Info-label(改成需要显示的中文名即可),但是需要安装到安卓手 ...

  6. 经典收藏 50个jQuery Mobile开发技巧集萃

    http://www.cnblogs.com/chu888chu888/archive/2011/11/10/2244181.html 1.Backbone移动实例 这是在Safari中运行的一款Ba ...

  7. Maven 安装以及一些开发技巧

    解压 apache-maven-3.2.5 在conf ->sites中配置repository 的路径. Eclipse 配置 maven 2. 3. 一些小BUG 或开发技巧 eclipse ...

  8. thinkphp开发技巧经验分享

    thinkphp开发技巧经验分享 www.111cn.net 编辑:flyfox 来源:转载 这里我给大家总结一个朋友学习thinkphp时的一些笔记了,从变量到内置模板引擎及系统变量等等的笔记了,同 ...

  9. Java 8的五大开发技巧

    转载:http://geek.csdn.net/news/detail/94219 在Java 9发布之前,我们来分享一些Java 8开发技巧,本文翻译自JetBrains高级开发主管Trisha G ...

随机推荐

  1. leetcode 【 Linked List Cycle II 】 python 实现

    公司和学校事情比较多,隔了好几天没刷题,今天继续刷起来. 题目: Given a linked list, return the node where the cycle begins. If the ...

  2. day05_06 continue语句、while循环

    输入满3次跳出,然后留一句话 for i in range(3): username = input("Username:") password = input("Pas ...

  3. js后台提交成功后 关闭当前页 并刷新父窗体(转)

    原文地址:http://www.cnblogs.com/chenghu/p/3696433.html 后台提交成功后 关闭当前页 并刷新父窗体 this.ClientScript.RegisterSt ...

  4. HDU5726 GCD

    Give you a sequence of N(N≤100,000)N(N≤100,000) integers : a1,...,an(0<ai≤1000,000,000)a1,...,an( ...

  5. Spring框架配置beans.xml扩展

    Spring学习笔记(二) 续Spring 学习笔记(一)之后,对Spring框架XML的操作进行整理 1 什么是IOC(DI) IOC = inversion of control   控制反转 D ...

  6. GitLab-CI环境搭建与操作手册

    第一章 系统安装简介 1.1. 系统结构 GitLab-CI持续集成服务主要包括gitlab.runner 2个模块.Gitlab主要负责代码文件的管理:runner则负责版本编译.存储.推送等任务. ...

  7. P2165 [AHOI2009]飞行棋

    题目描述 给出圆周上的若干个点,已知点与点之间的弧长,其值均为正整数,并依圆周顺序排列. 请找出这些点中有没有可以围成矩形的,并希望在最短时间内找出所有不重复矩形. 输入输出格式 输入格式: 第一行为 ...

  8. BZOJ 3876 支线剧情(有上下界的无源汇最小费用可行流)

    3876: [Ahoi2014]支线剧情 Time Limit: 10 Sec  Memory Limit: 256 MB Submit: 1783  Solved: 1079 [Submit][St ...

  9. HDU 1811 Rank of Tetris(并查集按秩合并+拓扑排序)

    Rank of Tetris Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  10. HDU 4614 Vases and Flowers(线段树+二分)

    Vases and Flowers Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others ...