美文网首页
杂七杂八

杂七杂八

作者: 音吹 | 来源:发表于2016-08-31 11:48 被阅读14次

NS_REQUIRES_NIL_TERMINATION

<code>titles:(NSString *)firstTitle, ... NS_REQUIRES_NIL_TERMINATION</code>

列表foot和header不滑动

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGFloat sectionHeaderHeight = 40;
    if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
        scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
    }else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
        scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
    }
}

剪裁图片尺寸

- (UIImage *)scaleFromImage:(UIImage *)image toSize:(CGSize)size
{
    UIGraphicsBeginImageContext(size);
    [image drawInRect:CGRectMake(0, 0, size.width, size.height)];
    UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage;
    
}

时间戳

//时间戳 转成 时间
- (NSString *)dateTo:(NSString *)str
{
    NSTimeInterval time=[str integerValue];
    
    NSDate *detaildate=[NSDate dateWithTimeIntervalSince1970:time];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    
    //设定时间格式,这里可以设置成自己需要的格式
    
    [dateFormatter setDateFormat:@"yyyy-MM-dd"];
    
    NSString *currentDateStr = [dateFormatter stringFromDate: detaildate];
    return currentDateStr;
}

//时间 转成 时间戳
- (NSString *)dateFromString:(NSString *)dateString{
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    
    [dateFormatter setDateFormat: @"yyyy-MM-dd"];
    
    
    
    
    NSDate *destDate= [dateFormatter dateFromString:dateString];
    NSString * timeSp = [NSString stringWithFormat:@"%ld",(long)[destDate timeIntervalSince1970]];
    return timeSp;
    
}

获取视频封面图片

- (UIImage *)thumbnailImageForVideo:(NSURL *)videoURL atTime:(NSTimeInterval)time{
    AVURLAsset * asset = [[AVURLAsset alloc] initWithURL:videoURL options:nil];
    NSParameterAssert(asset);
    AVAssetImageGenerator * assetImageGenerator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
    
    assetImageGenerator.appliesPreferredTrackTransform = YES;
    assetImageGenerator.apertureMode =AVAssetImageGeneratorApertureModeEncodedPixels;
    
    CGImageRef thumnailImageRef = NULL;
    CFTimeInterval thumnailImageTime = time;
    NSError * thumnailImageGenerationError = nil;
    thumnailImageRef = [assetImageGenerator copyCGImageAtTime:CMTimeMake(thumnailImageTime, 60) actualTime:NULL error:&thumnailImageGenerationError];
    if (!thumnailImageRef) {
        NSLog(@"%@",thumnailImageGenerationError);
    }
    UIImage * thumbnailImage = thumnailImageRef?[[UIImage alloc] initWithCGImage:thumnailImageRef]:nil;
    return thumbnailImage;
}

书名

    NSString *dbPath = [NSHomeDirectory() stringByAppendingString:@"/Documents"];
    NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager]enumeratorAtPath:dbPath];
    for (NSString *fileName in enumerator)
    {
        NSLog(@"书名:   %@",fileName);
    }

相关文章

  • 一些杂七杂八的说说

    这些年来,有一些杂七杂八的个人感受,一些杂七杂八的个人观点,于是就有了这篇杂七杂八的个人说说。 片断感受一: 的确...

  • 小画

    杂七杂八的比较多

  • linux 常用命令

    linux 常用命令 杂七杂八

  • 杂记第3天

    早餐:家常早餐。午餐:馄饨和一些杂七杂八。晚餐:接着吃了一些杂七杂八。 运动:下身力量训练时间半小时。 阅读:《下...

  • 杂七杂八!

  • 【杂七杂八】

    文/现实糟蹋了梦想 错位的灵魂 指引着 错位的身体 站在了错位的身份上 寒风把古筝弹起 引来了漫天的黑云 遮住了阳...

  • 杂七杂八

    爸爸最近身体不舒服,体重下降的厉害,明天上午需要跟他去医院查一下肝脏、甲状腺、血糖等方面,现在又咳嗽了,真是为他的...

  • 杂七杂八

    想要一份默契十足的长久爱情:想和你用黑白两色、充电五分钟通话一小时的手机,就算不见面我也想叽叽喳喳和你斗嘴。夏天也...

  • 杂七杂八

    拔牙后的第三天,伤口还是有点不舒服,连带着头也开始疼了。打开手机的照相功能当镜子,查看伤口,悲催的是,手机自...

  • 杂七杂八

    是不是人的活着,都是这样,每个阶段的烦恼都解不开,大人是不是在小时候也有过同一种纠结。 20多岁真...

网友评论

      本文标题:杂七杂八

      本文链接:https://www.haomeiwen.com/subject/llbqettx.html