iOS7开发技巧
和任何新的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开发技巧的更多相关文章
- 移动 Web 开发技巧之(后续)
昨天的<移动 Web 开发技巧>的这篇文章,大家反响不错,因为这些问题在大家日常写移动端的页面时经常遇到的.所以那个文章还是超级实用的,那么我们今天继续来分享一下移动端的web开发技巧吧, ...
- 移动端web开发技巧(转)
原文链接:http://liujinkai.com/2015/06/06/mobile-web-skill/ 移动端web开发技巧 这是一个最好的时代,因为我们站在潮流中:但也是一个最坏的时代,因为我 ...
- SQL开发技巧(二)
本系列文章旨在收集在开发过程中遇到的一些常用的SQL语句,然后整理归档,本系列文章基于SQLServer系列,且版本为SQLServer2005及以上-- 文章系列目录 SQL开发技巧(一) SQL开 ...
- DelphiXE2 DataSnap开发技巧收集
DelphiXE2 DataSnap开发技巧收集 作者: 2012-08-07 09:12:52 分类:Delphi 标签: 作为DelphiXE2 DataSnap开发的私家锦囊, ...
- delphi XE5下安卓开发技巧
delphi XE5下安卓开发技巧 一.手机快捷方式显示中文名称 project->options->Version Info-label(改成需要显示的中文名即可),但是需要安装到安卓手 ...
- 经典收藏 50个jQuery Mobile开发技巧集萃
http://www.cnblogs.com/chu888chu888/archive/2011/11/10/2244181.html 1.Backbone移动实例 这是在Safari中运行的一款Ba ...
- Maven 安装以及一些开发技巧
解压 apache-maven-3.2.5 在conf ->sites中配置repository 的路径. Eclipse 配置 maven 2. 3. 一些小BUG 或开发技巧 eclipse ...
- thinkphp开发技巧经验分享
thinkphp开发技巧经验分享 www.111cn.net 编辑:flyfox 来源:转载 这里我给大家总结一个朋友学习thinkphp时的一些笔记了,从变量到内置模板引擎及系统变量等等的笔记了,同 ...
- Java 8的五大开发技巧
转载:http://geek.csdn.net/news/detail/94219 在Java 9发布之前,我们来分享一些Java 8开发技巧,本文翻译自JetBrains高级开发主管Trisha G ...
随机推荐
- vue/vux编译时出现 unexpected token <11:0-485>
最近开发Vux项目,一直使用VS Code开发工具,可以格式化里面的<script>代码的: 但是今天突然无法格式化代码,而且编译报错.主要提示类似:unexpected token & ...
- Android TextWatcher的使用方法(监听ExitText的方法)
我做了一个查询单词的简单app, 当在EditText中输入单词的时候,点击lookup,则在TextView区域显示出该单词的意思,当EditText中没有任何字符时,显示"word de ...
- mybatis sql转义符号
第一种写法:通过<![CDATA[ ]]>符号来写 大于等于:<![CDATA[ >= ]]> 小于等于:<![CDATA[ <= ]]> 例如:sql ...
- Python面向对象之私有方法(4)
类里面有很多成员修饰符,用来修饰各种属性 (1)私有属性,只有内部的方法可以访问 class Foo: xo = 'xo'#表明是公共的,内部外部都可以访问 __ox = '私有属性'#私有属性,只有 ...
- spring bean自动注入
使用 @Repository.@Service.@Controller 和 @Component 将类标识为 Bean Spring 自 2.0 版本开始,陆续引入了一些注解用于简化 Spring 的 ...
- mac最新系统安装beego出现kiil 9
(内容来自:http://www.oschina.net/question/2626413_2237311) 应该是最新mac OS 12.04的锅. 现在的解决办法是回退bee到以前版本. cd $ ...
- 使用caffe测试自己的图片
第一种方法是测试批量图片,使用caffe.bin即可,首先要做的是把你的jpg图片转换为LMDB的格式,如何转换呢?用/build/tools/convert_image --resize_width ...
- jQuery基础 浅析(含基本方法和选择器)
1.jQuery与DOM互相转换 jQuery入库函数:$(document).ready(function(){}) $(function(){}) $(“#btn”):jQuery存储的是DOM对 ...
- Eclipse配置关联Tomcat并运行项目
打开Eclipse,单击“Window”菜单,选择最下方的“Preferences”. 单击“Server”选项,选择下方的“Runtime Environments”. 点击“Add”添加Tomca ...
- [LeetCode] Longest Common Prefix 字符串公有前序
Write a function to find the longest common prefix string amongst an array of strings. Hide Tags Str ...