摘要:因为emoji编码在android或者pc设备没有很好的支持,所以有时候为了禁止emoji表情的输入,因为关闭不了系统emoji的键盘,那只能根据编码把emoji表情过滤掉,写了一个NSString的拓展,用来判断是不是emoji编码:@implementation NSString(Emoji)+(BOOL)isContainsEmoji:(NSString *)string { __block BOOL isEomji = NO; [string enumerateSubstringsInRange:NSMakeRange(0, [string length]) options:N...
阅读全文
摘要:最近做应用用到定位,位置信息可以很容易由CLLocationManager得到(得到的经纬度在中国有偏移,需要纠偏)。但是怎么把特定经纬度的位置信息得到呢,查看了一下资料,发现了CLGeocoder这个类,可以把经纬度反转为位置信息。代码如下:-(void)reverseGeocodeForLocation:(CLLocationCoordinate2D)coordinate{ CLLocation *loacation = [[[CLLocation alloc] initWithLatitude:coordinate.latitudelongitude:coordinate.longit.
阅读全文
摘要:在iOS6.0以下,当系统收到内存警告,会先调- (void)didReceiveMemoryWarning ,不在当前页面的controller会继续调- (void)viewDidUnload 去释放不必要的view,所以我们可以在viewDidUnload把某些子view释放以回收内存。但是在iOS6.0以上,controller只会收到didReceiveMemoryWarning,不再调用viewDidUnload,也就是苹果不会去主动释放view。所以我们可以封装以下,让6.0以上和以下版本收到内存警告都统一调一个函数,以用来释放子view。代码如此:写一个基类BaseViewCo
阅读全文
摘要:我们都知道,在iOS 6.0以下,支持旋屏的函数如下:- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation我们只要对不同的interfaceOrientation返回YES或NO即可支持对应的屏幕旋转。在6.0以后,旋转函数改为:- (NSUInteger)supportedInterfaceOrientations需要自己返回对应的orientations。但是在实践中发现,当个controller的supportedInterfaceOrientations根本
阅读全文
摘要:今天发现工程里有同事代码如下:-(void)dealloc{ [self.indicatorViewrelease]; self.indicatorView = nil; [super dealloc];}这种低级错误必定导致崩溃。其实iOS本身一个property对象,如果是retain属性,调用它的赋值,其实是调用了如下代码:-(void)setIndicatorView:(UIActivityIndicatorView *)indicatorView{ if(indicatorView != _indicatorView){ [_indicatorViewrelease];...
阅读全文