跳转

#import "SZViewController.h"

@interface SZViewController ()<UITableViewDataSource,UITableViewDelegate>

{

    UITableView *tb;

}

@end

@implementation SZViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    self.title=@"设置";

    tb=[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];

    tb.dataSource=self;

    tb.delegate=self;

    [self.view addSubview:tb];

}

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

    return 2;

}

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

    if(section ==0) {

        return 9;

    }

    else {

        return 1;

    }

}

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


    UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"2"];


    if(!cell) {

        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"2"];

    }


    if(indexPath.section==0) {

        tb.rowHeight=40;

        NSArray *arr;

        arr = [NSArray arrayWithObjects:@"个人资料",@"账户与安全",@"我的地址",@"意见反馈",@"账号与s设备安全",@"证件信息",@"推送通知",@"清除缓存",@"关于贝店", nil];

        cell.textLabel.text=arr[indexPath.row];

    }

    else{

        UILabel *lb =[[UILabel alloc]initWithFrame:CGRectMake((self.view.frame.size.width-80)/2,0,80,40)];


        lb.text=@"退出登录";

        lb.textColor=[UIColor redColor];


        [cell addSubview:lb];


    }

    return cell;

}

@end

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一、简介 <<UITableView(或简单地说,表视图)的一个实例是用于显示和编辑分层列出的信息的一种手段 <<...
    无邪8阅读 10,692评论 3 3
  • 概述在iOS开发中UITableView可以说是使用最广泛的控件,我们平时使用的软件中到处都可以看到它的影子,类似...
    liudhkk阅读 9,091评论 3 38
  • Swift1> Swift和OC的区别1.1> Swift没有地址/指针的概念1.2> 泛型1.3> 类型严谨 对...
    cosWriter阅读 11,144评论 1 32
  • 前言 最近忙完项目比较闲,想写一篇博客来分享一些自学iOS的心得体会,希望对迷茫的你有所帮助。博主非科班出身,一些...
    GitHubPorter阅读 1,453评论 9 5
  • 版权声明:未经本人允许,禁止转载. 1. TableView初始化 1.UITableView有两种风格:UITa...
    萧雪痕阅读 2,919评论 2 10