• 计算图片的宽和高 动态设置图片的位置


      切记 : 计算图片的高度和宽度应该在请求数据的时候获取.然后保存起来 否则的话会造成卡顿现象     
     
    方法优化:
        WidthAndHeight *wAndH = _widthAndHeightDataArray[indexPath.row];
       
        CGFloat width = wAndH.widthPic;
       
        CGFloat height = wAndH.heightPic;
       
        CGRect picBackViewFrame = cell.picBackView.frame;
        cell.picBackView.frame = CGRectMake(0, picBackViewFrame.origin.y, SCREEN_WIDTH, SCREEN_WIDTH);
        cell.postPhoto.frame = CGRectMake(width / 2 > SCREEN_WIDTH ? 0 : ((SCREEN_WIDTH - width / 2) / 2), height / 2 > SCREEN_WIDTH ? 0 : ((SCREEN_WIDTH - height / 2) / 2), width / 2 > SCREEN_WIDTH ? SCREEN_WIDTH : (width / 2), height / 2 > SCREEN_WIDTH ? SCREEN_WIDTH : (height / 2));
     
    以下舍弃
    #pragma  mark - requestMore
    - (void)requestMore {
        [API selectNoteContentFrom:from to:to completion:^(NSError *error, id responseData) {
            if (!error) {
               
                for (NSDictionary *dic in responseData[@"result"]) {
                    FindContent *find = [[FindContent alloc] init];
                    [find setValuesForKeysWithDictionary:dic];
                   
                    UIImage *image = [[UIImage alloc] initWithData:[[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:find.imgList[0]]]];
                    WidthAndHeight *wAndH = [[WidthAndHeight alloc] init];
                    CGFloat width  = image.size.width;
                    CGFloat height = image.size.height;
                    wAndH.widthPic = width;
                    wAndH.heightPic = height;
                    [_widthAndHeightDataArray addObject:wAndH];
                    NSLog(@"**************************************%@", wAndH);
                    [_noteArray addObject:find];
                }
                [self.tableView reloadData];
            }
        }];
    }
    UIView*picBacgroundView;
            UIImageView *contentPic;
            for (int i = 0; i < imgArray.count; i++) {
           
        WidthAndHeight *wAndH = _widthAndHeightDataArray[indexPath.row];
       
        CGFloat width = wAndH.widthPic;
       
        CGFloat height = wAndH.heightPic;
                if (iPhone4) {
                    if (width / 2 > SCREEN_WIDTH) {
                        picBacgroundView.frame = CGRectMake(0, photoImage.frame.origin.y + photoImage.frame.size.height + 10 + SCREEN_WIDTH * i + 10 * i, SCREEN_WIDTH, SCREEN_WIDTH);
                        contentPic.frame = CGRectMake(0, 0 , SCREEN_WIDTH, SCREEN_WIDTH);
                    } else {
                        picBacgroundView.frame = CGRectMake(0, photoImage.frame.origin.y + photoImage.frame.size.height + 10 + SCREEN_WIDTH * i + 10 * i, SCREEN_WIDTH, SCREEN_WIDTH);
                        contentPic.frame = CGRectMake((SCREEN_WIDTH - width / 2) / 2, (SCREEN_WIDTH - height / 2) / 2 , width / 2, height / 2);
                    }
                } else if (iPhone5) {
                    if (width / 2 > SCREEN_WIDTH) {
                        picBacgroundView.frame = CGRectMake(0, photoImage.frame.origin.y + photoImage.frame.size.height + 10 + SCREEN_WIDTH * i + 10 * i, SCREEN_WIDTH, SCREEN_WIDTH);
                        contentPic.frame = CGRectMake(0, 0 , SCREEN_WIDTH, SCREEN_WIDTH);
                    } else {
                        picBacgroundView.frame = CGRectMake(0, photoImage.frame.origin.y + photoImage.frame.size.height + 10 + SCREEN_WIDTH * i + 10 * i, SCREEN_WIDTH, SCREEN_WIDTH);
                        contentPic.frame = CGRectMake((SCREEN_WIDTH - width / 2) / 2, (SCREEN_WIDTH - height / 2) / 2 , width / 2, height / 2);
                    }
                } else if (iPhone6) {
                    if (width / 2 > SCREEN_WIDTH) {
                        picBacgroundView.frame = CGRectMake(0, photoImage.frame.origin.y + photoImage.frame.size.height + 10 + SCREEN_WIDTH * i + 10 * i, SCREEN_WIDTH, SCREEN_WIDTH);
                        contentPic.frame = CGRectMake(0, 0 , SCREEN_WIDTH, SCREEN_WIDTH);
                    } else {
                        picBacgroundView.frame = CGRectMake(0, photoImage.frame.origin.y + photoImage.frame.size.height + 10 + SCREEN_WIDTH * i + 10 * i, SCREEN_WIDTH, SCREEN_WIDTH);
                        contentPic.frame = CGRectMake((SCREEN_WIDTH - width / 2) / 2, (SCREEN_WIDTH - height / 2) / 2 , width / 2, height / 2);
                    }
                } else {
                    picBacgroundView.frame = CGRectMake(0, photoImage.frame.origin.y + photoImage.frame.size.height + 10 + SCREEN_WIDTH * i + 10 * i, SCREEN_WIDTH, SCREEN_WIDTH);
                    contentPic.frame = CGRectMake((SCREEN_WIDTH - width / 2) / 2, (SCREEN_WIDTH - height / 2) / 2 , width / 2, height / 2);
                }
                [contentPic sd_setImageWithURL:[NSURL URLWithString:self.findContent.imgList[i]]];
                UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(pressPic:)];
                [contentPic addGestureRecognizer:tap];
                contentPic.userInteractionEnabled = YES;
                [picBacgroundView addSubview:contentPic];
            }
  • 相关阅读:
    Xna小游戏开发【飞机空间大战】 碧血黄沙
    参考XNA官方Platformer模版,修改Platformer为横版可以滚动的小游戏 碧血黄沙
    云计算「半步巅峰」
    get_custom_field使用
    CCTM_FormElement 类
    php opendir说明
    js(chrome)打印对象函数
    operamasks.omItemSelector获取右边框ID方法
    {$vo.CreateDate|date="ymd H:i:s",###}
    添加xmlns:android="http://schemas.android.com/apk/res/android"的意思
  • 原文地址:https://www.cnblogs.com/tian-sun/p/5019944.html
Copyright © 2020-2023  润新知