一个页面内要跳转不同的控制器,如个人中心页面
在百度地图的学习过程中,发现里面有一个不错的方法,怎么实现的呢?来分享一下!
- (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];
}
数组内有的随意写,不要见怪哦,重点在下面放大招了!! !