Skip to content

Instantly share code, notes, and snippets.

#define IS_RETINA ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)] && ([UIScreen mainScreen].scale == 2.0))
NSURL *imageUrl = [NSURL URLWithString:couponInfo.usingUrl];
NSData *imageData = [[NSData alloc] initWithContentsOfURL:imageUrl];
_avatar.image = [UIImage imageWithData:imageData];
@xfantasy
xfantasy / iOS sensor detect
Created December 26, 2013 14:19
检测各种传感器是否可用
// 检测是否存在摄像头
- (BOOL)isCameraAvailable
{
return [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
}
// 检测前置摄像头是否存在
- (BOOL)isFrontCameraAvailabel
{
#ifdef __IPHONE_4_0 // iPhone加入了前置摄像头