iOS 6.0不同版本内存警告的统一处理

摘要: 在iOS6.0以下,当系统收到内存警告,会先调- (void)didReceiveMemoryWarning ,不在当前页面的controller会继续调- (void)viewDidUnload 去释放不必要的view,所以我们可以在viewDidUnload把某些子view释放以回收内存。但是在iOS6.0以上,controller只会收到didReceiveMemoryWarning,不再调用viewDidUnload,也就是苹果不会去主动释放view。所以我们可以封装以下,让6.0以上和以下版本收到内存警告都统一调一个函数,以用来释放子view。代码如此:写一个基类BaseViewCo 阅读全文
posted @ 2013-05-28 22:16 VicStudio 阅读(316) 评论(0) 推荐(0) 编辑

iOS 6.0以上版本的旋屏控制处理

摘要: 我们都知道,在iOS 6.0以下,支持旋屏的函数如下:- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation我们只要对不同的interfaceOrientation返回YES或NO即可支持对应的屏幕旋转。在6.0以后,旋转函数改为:- (NSUInteger)supportedInterfaceOrientations需要自己返回对应的orientations。但是在实践中发现,当个controller的supportedInterfaceOrientations根本 阅读全文
posted @ 2013-05-27 21:58 VicStudio 阅读(224) 评论(0) 推荐(0) 编辑

iOS默认的set方法

摘要: 今天发现工程里有同事代码如下:-(void)dealloc{ [self.indicatorViewrelease]; self.indicatorView = nil; [super dealloc];}这种低级错误必定导致崩溃。其实iOS本身一个property对象,如果是retain属性,调用它的赋值,其实是调用了如下代码:-(void)setIndicatorView:(UIActivityIndicatorView *)indicatorView{ if(indicatorView != _indicatorView){ [_indicatorViewrelease];... 阅读全文
posted @ 2013-05-26 21:44 VicStudio 阅读(1007) 评论(0) 推荐(0) 编辑