tableView如何重載數(shù)據(jù)及刷新cell-創(chuàng)新互聯(lián)

本篇文章為大家展示了tableView如何重載數(shù)據(jù)及刷新cell,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過(guò)這篇文章的詳細(xì)介紹希望你能有所收獲。

成都創(chuàng)新互聯(lián)公司公司2013年成立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè)網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元城區(qū)做網(wǎng)站,已為上家服務(wù),為城區(qū)各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18982081108

#import "NewTitleTableViewController.h"

@interface NewTitleTableViewController ()<NSURLConnectionDataDelegate>
@property (nonatomic,retain) NSArray * arr;
@property (nonatomic ,retain) NSMutableData * data ;
@end

@implementation NewTitleTableViewController
- (void)dealloc
{
   self.data = nil;
   self.arr = nil;
   [super dealloc];
}
- (id)initWithStyle:(UITableViewStyle)style
{
   self = [super initWithStyle:style];
   if (self) {
       
   }
   return self;
}

- (void)viewDidLoad
{
   [super viewDidLoad];
   
   NSString * urlString = @"http://XXXXX";
   NSURL * url = [NSURL URLWithString:urlString];
   NSMutableURLRequest * request = [NSMutableURLRequest requestWithURL:url];
   NSString * parm = [NSString stringWithFormat:@"%@",@"?date=20131129&startRecord=10&len=30&udid=1234567890&terminalType=Iphone&cid=213"];
   NSData * parmData = [parm dataUsingEncoding:NSUTF8StringEncoding];
   //6 設(shè)置請(qǐng)求體
   [request setHTTPBody:parmData];
   //7 設(shè)置請(qǐng)求方式
   [request setHTTPMethod:@"POST"];


異步POST
   [NSURLConnection connectionWithRequest:request delegate:self];
  
}

代理方法:
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
   self.data = [NSMutableData data];
}

-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
   [self.data appendData:data];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
   
   NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:self.data options:NSJSONReadingMutableContainers error:nil];
       self.arr = dic[@"news"];
   [self.tableView reloadData];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
   
}



tableView datadelegate 方法:

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

   return 1;
}

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

   if (self.arr.count == 0) {
       return 1;
   }
   return self.arr.count;
}

cell 方法

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   static NSString * iden = @"fff";
   UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:iden];
   if (!cell) {
       cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:iden] autorelease];
   }
   
   if (self.arr[indexPath.row][@"title"] == nil)
   {
       cell.textLabel.text = @"加載中....";
   }
   else
   {
   cell.textLabel.text = self.arr[indexPath.row][@"title"];
   }
   return cell;
}



上述內(nèi)容就是tableView如何重載數(shù)據(jù)及刷新cell,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

當(dāng)前名稱:tableView如何重載數(shù)據(jù)及刷新cell-創(chuàng)新互聯(lián)
文章來(lái)源:http://bm7419.com/article46/cdeohg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、關(guān)鍵詞優(yōu)化網(wǎng)站導(dǎo)航、網(wǎng)站營(yíng)銷云服務(wù)器、定制開(kāi)發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

手機(jī)網(wǎng)站建設(shè)