oc 点击tableviewcell 怎么进入web
1个回答
展开全部
实现UITableView中点击不同cell进入不同Controller的方法
1>定义一个NSMutableArray的变量,如NSMutableArray *menuList;
2>将要加入cell的对象以字典的方式加入menuList中。
self.menuList = [NSMutableArray array];
//for showing various UIButtons:
ButtonsViewController *buttonsViewController = [[ButtonsViewController alloc] init];
[self.menuList addObject:[NSDictionary dictionaryWithObjectsAndKeys:
NSLocalizedString(@"ButtonsTitle",@""), kTitleKey,
NSLocalizedString(@"ButtonsExplain",@""), kExplainKey,
buttonsViewController, kViewControllerKey,
nil]];
[buttonsViewController release];
//for showing various UIControls:
ControlsViewController *controlsViewController = [[ControlsViewController alloc] init];
[self.menuList addObject:[NSDictionary dictionaryWithObjectsAndKeys:
NSLocalizedString(@"ControlsTitle",@""), kTitleKey,
NSLocalizedString(@"ControlsExplain",@""), kExplainKey,
controlsViewController, kViewControllerKey,
nil]];
//for showing various UITextFields:
TextViewController *textFieldViewController = [[TextViewController alloc] init];
[self.menuList addObject:[NSDictionary dictionaryWithObjectsAndKeys:
NSLocalizedString(@"TextFieldTitle",@""), kTitleKey,
NSLocalizedString(@"TextFieldExplain",@""), kExplainKey,
textFieldViewController,kViewControllerKey,
nil]];
[textFieldViewController release];
3。通过objectforKey取值。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIViewController *targetViewController = [[self.menuList objectAtIndex: indexPath.row] objectForKey:kViewControllerKey];
[[self navigationController] pushViewController:targetViewController animated:YES];
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询