今天再学习十个
1.cell去除选中效果
cell.selectionStyle = UITableViewCellSelectionStyleNone;
2.cell点按效果
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
3.当删除一个从xib拖出来的属性时,一定记得把xib中对应的线也删掉,不然会报类似[<ViewController 0x7fea6ed05980>setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key的crash
4.真机测试的时候报错:Could not launch "你的 App",process launch failed: Security
因为你的app没有上线,iOS9开始,需要手动信任Xcode生成的描述文件,打开手机设置->通用->描述文件->点击你的app的描述文件->点击信任
5.真机测试的时候报错:Could not find Developer Disk Image
这是因为你的设备系统版本大于Xcode能兼容的系统版本,比如你的设备是iOS10.3,而Xcode版本是8.2(Xcode8.2最大兼容iOS10.2),就会报这个错误。解决办法就是升级Xcode!
6.UITextView没有placeholder的问题?
网上有很多此类自定义控件,也可以参考下我写的一个UITextView分类 UITextView-WZB
7.移除字符串中的空格和换行
+ (NSString *)removeSpaceAndNewline:(NSString *)str {
NSString *temp = [str stringByReplacingOccurrencesOfString:@" " withString:@""];
temp = [tempstringByReplacingOccurrencesOfString:@"\r"withString:@""]; temp = [tempstringByReplacingOccurrencesOfString:@"\n"withString:@""];
return temp;
}
8.判断字符串中是否有空格
+ (BOOL)isBlank:(NSString *)str {
NSRange _range = [str rangeOfString:@" "];
if (_range.location != NSNotFound) {
//有空格
return YES;
} else {
//没有空格
return NO;
}
}
9.获取一个视频的第一帧图片
NSURL *url = [NSURL URLWithString:filepath];
AVURLAsset *asset1 = [[AVURLAsset alloc] initWithURL:url options:nil];
AVAssetImageGenerator *generate1 = [[AVAssetImageGenerator alloc] initWithAsset:asset1];
generate1.appliesPreferredTrackTransform = YES;
NSError *err = NULL;
CMTime time = CMTimeMake(1, 2);
CGImageRef oneRef = [generate1 copyCGImageAtTime:time actualTime:NULL error:&err];
UIImage *one = [[UIImage alloc] initWithCGImage:oneRef];
return one;
10.获取视频的时长
+ (NSInteger)getVideoTimeByUrlString:(NSString *)urlString {
NSURL *videoUrl = [NSURL URLWithString:urlString];
AVURLAsset *avUrl = [AVURLAsset assetWithURL:videoUrl];
CMTime time = [avUrl duration];
int seconds = ceil(time.value/time.timescale);
return seconds;
}
11.字符串是否为空
+ (BOOL)isEqualToNil:(NSString *)str {
return str.length <= 0 || [str isEqualToString:@""] || !str;
}
网友评论