<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ## 一:效果 沒有圖文混排,也沒有復雜的UI,僅僅是簡單的顯示出微博數據,主要介紹AFNetworking和SDWebImage的簡單用法 ![](https://box.kancloud.cn/2016-01-20_569f1d992ef9e.jpg) ## 二:加載數據AFNetworking ### AFNetworking用法 AFNetworking的用法大體有三步:? 一:下載第三方框架(githup也好,百度也好,多的是)? 二:導入頭文件?`#import "AFNetworking.h"`? 三:開始寫代碼(以上兩步所有的第三方框架都通用) 1,請求管理者 ~~~ AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManager manager]; ~~~ 2,拼接請求參數 ~~~ NSMutableDictionary *params = [NSMutableDictionary dictionary]; params[@"*****"] = @"*****"; params[@"*****"] = @"*****"; params[@"*****"] = @"*****"; 。。。。 ///可以寫很多參數 ~~~ 3,發送請求 ~~~ [mgr GET:@"https:請求的網址" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { //這里寫請求成功用的代碼 NSLog(@"請求成功 --- %@", responseObject); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { //這里寫請求失敗用的代碼 NSLog(@"請求失敗 --- %@",error); }]; ~~~ 下面貼出微博項目中的代碼 ### 加載最新的微博數據 ~~~ /** * //加載最新的微博數據 * * */ -(void)loadNewStatus { //1,請求管理者 AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManager manager]; //2,拼接請求參數 NSMutableDictionary *params = [NSMutableDictionary dictionary]; HWAccount *account = [HWAccountTool account]; params[@"access_token"] = account.access_token; // params[@"count"] = @20; //3,發送請求 [mgr GET:@"https://api.weibo.com/2/statuses/friends_timeline.json" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { HWLog(@"請求成功 --- %@", responseObject); //取得微博數組 self.statuses = responseObject[@"statuses"]; //刷新表格 [self.tableView reloadData]; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { HWLog(@"請求失敗 --- %@",error); }]; } ~~~ ## 三:SDWebImage用法 SDWebImage的用法大體有三步:? 一:下載第三方框架(githup也好,百度也好,多的是)? 二:導入頭文件?`#import "UIImageView+WebCache.h" (這里面很多頭文件,看自己具體需要那種了)`? 三:開始寫代碼(以上兩步所有的第三方框架都通用)? 這個代碼寫起來就更簡單了,例如微博中我們想要讓他自己下載緩存一張圖片用作每個tableViewCell的圖片,并且顯示一張占位圖片,一句代碼就搞定了 ~~~ [cell.imageView sd_setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:placehoder]; ~~~ 然后需要做防止程序內存溢出的操作? 一:在程序AppDelegate 中寫入頭文件`#import "SDWebImageManager.h"`? 二:調用方法,在整個程序內存警報時候調用`-(void)applicationDidReceiveMemoryWarning:(UIApplication *)application? ` 三:方法內寫入 ~~~ //整個程序內存警報時候調用 -(void)applicationDidReceiveMemoryWarning:(UIApplication *)application { SDWebImageManager *mgr = [SDWebImageManager sharedManager]; //1,取消下載 [mgr cancelAll]; //2,清除內存中的所有圖片 [mgr.imageCache clearMemory]; } ~~~ 這里貼出cell全部代碼供參考 ~~~ -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *ID = @"status"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; if (!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID]; } //用indexPathRow取出對應的一條微博字典 NSDictionary *status = self.statuses[indexPath.row]; //設置微博作者 NSDictionary *user = status[@"user"]; cell.textLabel.text = user[@"name"]; //設置微博內容 cell.detailTextLabel.text = status[@"text"]; //設置微博頭像 NSString *imageUrl = user[@"profile_image_url"]; //占位圖 UIImage *placehoder = [UIImage imageNamed:@"avatar_default_small"]; [cell.imageView sd_setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:placehoder]; return cell; } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看