本篇文章為大家展示了tableView如何重載數(shù)據(jù)及刷新cell,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。
成都創(chuàng)新互聯(lián)公司公司2013年成立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務公司,擁有項目成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè)網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元城區(qū)做網(wǎng)站,已為上家服務,為城區(qū)各地企業(yè)和個人服務,聯(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è)置請求體
[request setHTTPBody:parmData];
//7 設(shè)置請求方式
[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,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
另外有需要云服務器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
當前名稱:tableView如何重載數(shù)據(jù)及刷新cell-創(chuàng)新互聯(lián)
文章來源:http://www.muchs.cn/article46/cdeohg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、關(guān)鍵詞優(yōu)化、網(wǎng)站導航、網(wǎng)站營銷、云服務器、定制開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容