iOStableView的用法

- (void)viewDidLoad

創(chuàng)新互聯(lián)建站專注于鐵山網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠為您提供鐵山營銷型網(wǎng)站建設(shè),鐵山網(wǎng)站制作、鐵山網(wǎng)頁設(shè)計(jì)、鐵山網(wǎng)站官網(wǎng)定制、微信小程序開發(fā)服務(wù),打造鐵山網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供鐵山網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。

{

    [super viewDidLoad];


    UITableView *myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, Screen_width, Screen_height)style:UITableViewStylePlain];

//    UITableViewStyleGrouped分組

    myTableView.dataSource = self;

    myTableView.delegate = self;

    [self cancelCell:myTableView];

    [self.view addSubview:myTableView];

       // Do any additional setup after loading the view,;typically from a nib.

}


#pragma mark-once 行數(shù)

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

{

    return 3;

}


#pragma mark-once 行內(nèi)容

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

{

   static NSString *cellID = @"cellID";

    UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:cellID];

    if(cell==nil)

    {

        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];

    }

    //UITableViewCellStyle          是個(gè)枚舉

    //UITableViewCellStyleDefault;  默認(rèn)的

    //UITableViewCellStyleSubtitle;

    //UITableViewCellStyleValue1;

    //UITableViewCellStyleValue2;

    cell.textLabel.text = [NSString stringWithFormat:@"%ld",(long)indexPath.row];

    

    //給右邊加個(gè)標(biāo)識符的

    cell.accessoryType  =UITableViewCellAccessoryDisclosureIndicator;

    //選中的顏色

    cell.selectionStyle = UITableViewCellSelectionStyleBlue;

    

    return cell;

}


#pragma mark-once 幾組

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

{

    return 2;

}


#pragma mark-once頭標(biāo)題

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

{

  return @"第一個(gè)標(biāo)題";

}


#pragma mark-once未標(biāo)題

- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section

{

    return @"最后一個(gè)標(biāo)題";

 

}


#pragma mark-once標(biāo)識符accessoryButtonTappedForRow方法

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath

{


}


#pragma mark-once類似電話那種最右邊的 a,b,c,d,e-z

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView

{

    NSArray *rightArry = @[@"A",@"B",@"c",@"d",@"e",@"f",@"g"];

    return rightArry;

}

#pragma mark-once行高

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

{

    return 50;

}


#pragma mark-once頭標(biāo)題的高度

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

{

    return 50;

}


#pragma mark-once未標(biāo)題的高度

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section

{

    return 50;

}


#pragma mark-once行高

-(void)cancelCell:(UITableView *)tableView

{

    UIView *view = [UIView new];

    view.backgroundColor = [UIColor clearColor];

    [tableView setTableFooterView:view];

    view.frame = CGRectMake(0, 0, tableView.frame.size.width, 20);

}


#pragma mark-once 選中的方法

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

{

    NSLog(@"%ld",(NSInteger)indexPath.row);

}


#pragma mark-once編輯的方法

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath

{

    return YES;

}


#pragma mark-once是否允許移動(dòng)

- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath

{

    return YES;

}


#pragma mark-once 編輯的方法

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

{

}


#pragma mark-once 移動(dòng)的方法

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath*)destinationIndexPath

{


}

#pragma mark-once 分割線

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

    

    if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) {

        [tableView setSeparatorInset:UIEdgeInsetsZero];

    }

    

    if ([tableView respondsToSelector:@selector(setLayoutMargins:)]) {

        [tableView setLayoutMargins:UIEdgeInsetsZero];

    }

    

    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {

        [cell setLayoutMargins:UIEdgeInsetsZero];

    }

}

分享題目:iOStableView的用法
轉(zhuǎn)載來于:http://muchs.cn/article40/ghiieo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供服務(wù)器托管、面包屑導(dǎo)航網(wǎng)站排名、網(wǎng)站改版Google、品牌網(wǎng)站制作

廣告

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

h5響應(yīng)式網(wǎng)站建設(shè)