<3-1> 判断当前设备是否越狱
+(BOOL)isJailbroken {
BOOL isJailbroken = NO;
NSString *cydiaPath = @”/Applications/Cydia.app”;
NSString *aptPath = @”/private/var/lib/apt/”;
if ([[NSFileManager defaultManager] fileExistsAtPath:cydiaPath]
|| [[NSFileManager defaultManager] fileExistsAtPath:aptPath]){
isJailbroken = YES;
}
return isJailbroken ;
}
<3-2> 隐藏状态
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
[tableView setContentOffset:CGPointMake(0, 0) animated:NO];
<3-4>代码方式给UIButton绑定事件
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
[button addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
button.cancelsTouchesInView = NO; //让手势不把事件消耗掉,可以继续向下传递
<3-5> 使用手势给图片绑定单击事件
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
imageView.userInteractionEnabled = YES;
UITapGestureRecognizer *singleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(imageSingleTapAction:)];
[imageView addGestureRecognizer:singleTapGesture];
<3-6>检查协议方法
if(delegate && [delegate conformsToProtocol:@protocol(CopyDelegate)])
{
}
<3-7> 无缓存方式加载图片
[UIImage imageNamed]此方法加载图片会保存该图片的缓存,提供高速访问,程序结束才释放。
多图片使用时不宜使用,尤其是在Cell里面。
Cell里面可以使用下面的代码
NSString *imageName = @"image001.png";
NSRange range = [imageName rangeOfString:@"."];
NSString *file = [[NSBundle mainBundle] pathForResource:[imageName substringToIndex:range.location] ofType:[imageName pathExtension]];
NSData *imageData = [NSData dataWithContentsOfFile:file];
[self.imageView setImage:[UIImage imageWithData:imageData]];