zoukankan      html  css  js  c++  java
  • lol盒子重点内容

    //AFN函数 — imageview载入网络图片而且获取图片,获取之后存储到手机
      [image setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",skin.bigImg]] ] placeholderImage:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
            UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
    - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
    {
       
    if (error) {
            [
    self showToastWithText:@"不同意保存"];
        }
    else{
            [
    self showToastWithText:@"保存成功"];
        }
    }

    _player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:file] error:nil];
    //            NSLog(@"%@",[NSURL fileURLWithPath:file]);
    //            [_player play];
    //audioplayer第三方类库播放文件
               
    AudioPlayer *player = [AudioPlayer sharePlayer];
                [player playWithDataSourceType:DataSourceTypeLocal withURLString:file];

        //下载文件
               
    NSString *string = [NSString stringWithFormat:HERO_SOUND_DESC_URL,pathName,fileName];
               
    NSURL *url = [NSURL URLWithString:[string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
               
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
               
               
    AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
                operation.
    inputStream = [NSInputStream inputStreamWithURL:url];
                operation.
    outputStream = [NSOutputStream outputStreamToFileAtPath:file append:NO];
                [operation
    setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
                   
    NSLog(@"下载成功");
                    [
    _tableview reloadData];
                }
    failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                   
    NSLog(@"下载失败");
                }];
                [operation start];
    //在停止滑动的时候将scrollview的缩放变为1倍
    -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
    {
        _pageIndex = scrollView.contentOffset.x/SCREEN_WIDTH;
       
       
    for (UIScrollView *scrollview in scrollView.subviews)
        {
           
    if ([scrollview isKindOfClass:[UIScrollView class]]) {
                [scrollview setZoomScale:1.0];
            }
        }
       
    HeroSkin *skin = [_heroskin objectAtIndex:_pageIndex];
       
    _namelabel.text = skin.name;
       
    _pricelabel.text = skin.price;
       
    _pagelabel.text = [NSString stringWithFormat:@"%ld of %lu",_pageIndex+1,(unsigned long)_heroskin.count];
       
    NSLog(@"%ld",(long)_pageIndex);
    }

    //图片摇动
    -(
    void)ImageShake
    {
       
    CABasicAnimation *basic = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
        basic.
    fromValue = [NSNumber numberWithFloat:-M_PI/16];
        basic.
    toValue = [NSNumber numberWithFloat:M_PI/16];
        basic.
    duration = 0.1;
        basic.
    repeatCount = 3;
        [imageview.layer addAnimation:basic forKey:@"animateLayer"];
    //震动一次
        AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
    }

    //检測motion
    -(
    void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
    {
       
    if (motion == UIEventSubtypeMotionShake) {
            [
    self ImageShake];
            [
    player play];
        }
    }

    //计算string字符串的frame大小
    -(
    CGSize)getStringRect:(NSString *)str
    {
       
    if (str.length<1) {
           
    return CGSizeMake(0, 0);
        }
       
    CGSize size;
       
    NSAttributedString *string = [[NSAttributedString alloc]initWithString:str];
       
    //    NSDictionary *attribute= @{NSFontAttributeName:@12};
        size = [string
    boundingRectWithSize:CGSizeMake(280, 500) options:NSStringDrawingTruncatesLastVisibleLine |
               
    NSStringDrawingUsesLineFragmentOrigin |
               
    NSStringDrawingUsesFontLeading context:nil].size;
       
    return size;
    }

    -(CGFloat)caculateLabelHeightWith:(float)fontsize String:(NSString *)str
    {
       
    UIFont *font = [UIFont systemFontOfSize:fontsize];
       
    CGSize size = CGSizeMake(300,700);
       
    CGSize descriptionSize = [str sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByWordWrapping];
       
    return descriptionSize.height;
    }
  • 相关阅读:
    《JS权威指南学习总结--3.8类型转换》
    php基础-1
    django的url分配和url捕获参数
    Django项目的创建和设计模式
    1.Tensorflow的基本概念:
    linux下安装pycharm
    url参数和字典的相互转化
    MySQL数据库一
    利用伪装文件夹实现对文件的加密-当然如果你懂,这是很好破解的,只是障眼法而已
    数组有N+M个数字, 数字的范围为1 ... N, 打印重复的元素, 要求O(M + N), 不可以用额外的空间
  • 原文地址:https://www.cnblogs.com/zfyouxi/p/4511938.html
Copyright © 2011-2022 走看看