和任何新的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. Java -X命令

    C:\Users\Administrator>java -X -Xmixed 混合模式执行 (默认) -Xint 仅解释模式执行 -Xbootclasspath:<用 ; 分隔的目录和 z ...

  2. 【Minimum Path Sum】cpp

    题目: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right w ...

  3. 【Search In Rotated Sorted Array】cpp

    题目: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7  ...

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

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

  5. idea热部署设置(复制)

    提出问题 IntelliJ IDEA工具如何设置热部署??? 解决问题 我的IDEA的版本是:IntelliJ IDEA 14.0.2 第一步:打开tomcat配置 这里写图片描述 第二步: 这里写图 ...

  6. redis学习(二)redis.conf文件配置

    转自: https://www.cnblogs.com/pqchao/p/6558688.html 为了更好的使用redis,我们需要详细的了解redis配置文件及相关参数作用. bind 127.0 ...

  7. LESS CSS使用方法 , CSS也能跟JS一样玩

    本文转自  http://blog.csdn.net/xuyonghong1122/article/details/51986472 在使用CSS的时候,总会有这个想法 这个属性值老是重复写好烦 这个 ...

  8. canvas游戏开发系列(1):基础知识

    canvas基础知识 canvas是什么? canvas是html5的一个元素,可以说他的功能是html元素中最强大的一个. 举个栗子: 第一步:在页面中引入canvas标签,并且设置好宽高背景等样式 ...

  9. Mybatis Plugin插件安装破解及使用

    2018年2月更新 2018年2月份,提供一个网上比较多的一个版本V3.21版本,下载资源里面有个已整合版直接解压放入C:\Users\你的用户名\.IntelliJIdea2017.3\config ...

  10. 收集邮票(bzoj 1426)

    Description 有n种不同的邮票,皮皮想收集所有种类的邮票.唯一的收集方法是到同学凡凡那里购买,每次只能买一张,并且买到的邮票究竟是n种邮票中的哪一种是等概率的,概率均为1/n.但是由于凡凡也 ...