一个页面内要跳转不同的控制器,如个人中心页面

在百度地图的学习过程中,发现里面有一个不错的方法,怎么实现的呢?来分享一下!

- (void)viewDidLoad

{

    [super viewDidLoad];

    _demoNameArray = [[NSArray alloc]initWithObjects:

                      @"基本地图功能-MapViewBaseDemo",

                      @"多地图使用功能-MultiMapViewDemo",

  @"图层展示功能-MapViewDemo",

                      @"地图操作功能-MapViewControlDemo",

                      @"UI控制功能-MapViewUISettingDemo",

  @"定位功能-LocationDemo",

  nil];

    _viewControllerTitleArray = [[NSArray alloc]initWithObjects:

                                 @"基本地图功能",

                                 @"多地图使用功能",

                                 @"图层展示功能",

                                 @"地图操作功能",

                            nil];

    

    _viewControllerArray = [[NSArray alloc]initWithObjects:

                            @"MapViewBaseDemoViewController",

                            @"MultiMapViewDemo",

                            @"MapViewDemoViewController",

         

                            nil];

self.title = [NSString stringWithFormat: @"欢迎使用百度地图iOS SDK %@", BMKGetMapApiVersion()];

    //适配ios7

    if( ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0))

    {

        self.navigationController.navigationBar.translucent = NO;

    }

}

 

#pragma mark -

#pragma mark Table view data source

// Customize the number of rows in the table view.

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

    return _demoNameArray.count;

}

 

// Customize the appearance of table view cells.

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

    

    static NSString *CellIdentifier = @"BaiduMapApiDemoCell";

    

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

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

    }

    cell.textLabel.text = [_demoNameArray objectAtIndex:indexPath.row];

    return cell;

}

#pragma mark -

#pragma mark Table view delegate

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

    UIViewController* viewController = [[NSClassFromString([_viewControllerArray objectAtIndex:indexPath.row]) alloc] init];

    viewController.title = [_viewControllerTitleArray objectAtIndex:indexPath.row];

    UIBarButtonItem *customLeftBarButtonItem = [[UIBarButtonItem alloc] init];

    customLeftBarButtonItem.title = @"返回";

    self.navigationItem.backBarButtonItem = customLeftBarButtonItem;

    [self.navigationController pushViewController:viewController animated:YES];

}

数组内有的随意写,不要见怪哦,重点在下面放大招了!! !

转载于:https://www.cnblogs.com/fengkuangIT/p/4961362.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值