zoukankan      html  css  js  c++  java
  • 网络(第三方)异步请求图片

    //

    //  Home_ViewController.m

    //  框架

    //

    //  Created by zhusongxiu on 15/7/30.

    //  Copyright (c) 2015年 zhusongxiu. All rights reserved.

    //

    #import "Home_ViewController.h"

    #import "MyTableViewCell.h"

    #import "Activeties_ViewController.h"

    #import "UserCenter_ViewController.h"

    #import <BmobSDK/Bmob.h>

    #import "UIImageView+WebCache.h"

    @interface Home_ViewController ()<UITableViewDataSource,UITableViewDelegate>

    {

        

        NSArray *titlelist;

        NSMutableDictionary *imageDic;

        NSMutableArray *imageARR;

        

    }

    @end

    @implementation Home_ViewController

    - (void)viewDidLoad {

        [super viewDidLoad];

    //    self.title = @"景点大全";

        

        

        [self creatTableview];

    //    UIView *fed = [[UIView alloc]initWithFrame:CGRectMake(32, 434, 43, 52)];

    //    fed.backgroundColor = [UIColor redColor];

    //    [self.view addSubview:fed];

        

        [self loadData];

    }

    #warning 第三方============

    -(void)loadData{

        

        

        BmobQuery   *bquery = [BmobQuery queryWithClassName:@"GameScore"];

        //查找GameScore表的数据

        [bquery findObjectsInBackgroundWithBlock:^(NSArray *array, NSError *error) {

            

            

            imageARR = [NSMutableArray array];

    //        for (BmobObject *obj in array) {

    //            //打印playerName

    //            NSLog(@"obj.playerName = %@", [obj objectForKey:@"playerName"]);

    //            //打印objectId,createdAt,updatedAt

    ////            NSLog(@"obj.objectId = %@", [obj objectId]);

    ////            NSLog(@"obj.createdAt = %@", [obj createdAt]);

    ////            NSLog(@"obj.updatedAt = %@", [obj updatedAt]);

    //            

    //            imageDic = [NSMutableDictionary dictionary];

    //            [imageDic setValue:[obj objectForKey:@"ewewe" ] forKey:@"ewewe"];

    //            

    //            

    //            NSLog(@"=========%@",imageDic);

    //

    //

    //          

    //            

    //            [imageARR addObject:imageDic];

    //            

    //            NSLog(@"------%@",imageARR);

    //            

    ////             [self creatTableview];

    //        }

          

    //        imageARR = [NSMutableArray array];

    //        for (BmobObject *obj in array) {

    //            imageDic = [NSMutableDictionary dictionary];

    //            [imageDic setObject:[obj objectForKey:@"ewewe"] forKey:@"ewewe"];

    //            [imageARR addObject:imageDic];

            

            

    //        }

            imageARR = [NSMutableArray array];

            

            for (BmobObject *obj in array) {

                imageDic = [NSMutableDictionary dictionary];

                [imageDic setValue:[obj objectForKey:@"ewewe"] forKey:@"ewewe"];

                

                [imageARR addObject:imageDic];

                

            }

            

            

           

        }];

        

        

        

        

        

    }

    -(void)creatTableview{

        UITableView *tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)-115) style:UITableViewStylePlain];

        tableview.delegate = self;

        tableview.dataSource= self;

        

        [self.view addSubview:tableview];

        

        titlelist = @[@"ww",@"qq",@"zz",@"ss",@"xx"];

        for (int i =0; i <5; i ++) {

           

        

        }

     }

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

        

        Activeties_ViewController *act = [[Activeties_ViewController alloc]init];

        UserCenter_ViewController *USER = [[UserCenter_ViewController alloc]init];

        switch (indexPath.row) {

            case 0:

            {

                [self.navigationController pushViewController:act animated:YES];

            }

            break;

            case 1:

            {

                [self.navigationController pushViewController:USER animated:YES];

            }

                break;

            default:

                break;

        }

        

    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    //    return titlelist.count;

        return 5;

        

    }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

    {

       NSString *cellID = @"re";

        MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];

        if (!cell) {

            cell = [[MyTableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];

            }

        [tableView deselectRowAtIndexPath:indexPath animated:YES];

        cell.daibiaoImae.image = [UIImage imageNamed:@".jpg"];

        cell.qianggouNLable.text = @"抢购中";

        cell.qianggouNLable.textAlignment = YES;

        

        cell.priceLable.text = @"¥699999";

        cell.priceLable.textAlignment = YES;

        

        cell.subLable.text = @"¥666666";

        cell.subLable.textAlignment= YES;

        cell.subLable.font = [UIFont systemFontOfSize:14];

        

        cell.shituImae.image = [UIImage imageNamed:@"活动H.png"];

        

        cell.dizhiNLable.text = @"贵阳-北京";

        cell.dizhiNLable.textAlignment= YES;

        

        cell.DayLable.text = @"贵州7日游";

        

        cell.DayLable.textAlignment= YES;

        

    //    NSURL *url = [NSURL URLWithString:imageARR[indexPath.row][@"ewewe"]];

    //    

    //    NSLog(@"---------%@",url);

    //    NSURLRequest *request = [NSURLRequest requestWithURL:url];

    //    NSOperationQueue *queue = [[NSOperationQueue alloc]init];

    //    [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {

    //        cell.imageView.image = [UIImage imageWithData:data];

    //    }];

        

        

    //    if (indexPath.row == 1) {

    //        cell.daibiaoImae.contentMode = UIViewContentModeTopLeft;

    //        cell.daibiaoImae.image = [UIImage imageNamed:@"8.jpg"];

        

    //    }

        

        [cell.daibiaoImae sd_setImageWithURL:[NSURL URLWithString:imageARR[indexPath.row][@"ewewe"]]];

        

        

    //    查询数组中包含某个元素的记录

    //    [cell.daibiaoImae sd_setImageWithURL:[NSURL URLWithString:imageARR[indexPath.row][@"ewewe"]] ];

        

        

        return cell;

        

    }

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

        

        return 200;

    }

    - (void)didReceiveMemoryWarning {

        [super didReceiveMemoryWarning];

        // Dispose of any resources that can be recreated.

    }

    /*

    #pragma mark - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

        // Get the new view controller using [segue destinationViewController].

        // Pass the selected object to the new view controller.

    }

    */

    @end

  • 相关阅读:
    九度OJ 1035:找出直系亲属 (二叉树、递归)
    九度OJ 1034:寻找大富翁 (排序)
    九度OJ 1033:继续xxx定律 (基础题)
    九度OJ 1032:ZOJ (基础题)
    centos 6.4 安装mongodb
    数据校验工具类
    《 mongodb 学习 》java 基本操作
    《 mongodb 学习 》基本操作2
    《 mongodb 学习 》之基本操作
    《 mongodb 学习 》之安装篇
  • 原文地址:https://www.cnblogs.com/wukun16/p/4850309.html
Copyright © 2011-2022 走看看