【发布时间】:2015-10-05 09:25:51
【问题描述】:
我有一个包含动态原型内容的表格视图。我想在动态单元格点击时以编程方式调用特定的 ViewController。我为我的项目使用了SWRevealViewController 调用。
当我点击带有@"l1" 标识符的单元格时,我想加载带有sw_front 的主视图控制器,用于SWRevealViewController。我不能使用 controll+drag 因为在她身上我使用了tabviewcontrller。当我这样做时,它会消失标签栏。
#import "ListViewController.h"
@interface ListViewController ()
@end
@implementation ListViewController
{
NSArray *menuItems;
}
- (void)viewDidLoad {
[super viewDidLoad];
menuItems = [NSArray arrayWithObjects:@"l1",@"l2",@"l3",@"l6",@"l4",@"l5",@"l7", nil];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [menuItems count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = [menuItems objectAtIndex:indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if ([cell.reuseIdentifier isEqualToString:@""]) {
UIViewController *mainviewcontroller = [[UIViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:mainviewcontroller];
[self.navigationController presentViewController:navi animated:YES completion:nil];
}
}
【问题讨论】:
-
- (void)tableView:(UITableView *)tableView1 didSelectRowAtIndexPath:(NSIndexPath *)indexPath 使用此方法获取点击了哪个单元格
-
你想用 SWRevealViewController 改变当前可见的 ViewController 和另一个 ViewController 还是你想 push segue?
-
你使用了故事板或 xib
-
我使用故事板@Anbu.Karthik
-
是的,我想用 swrevealviewcontroller 和 sw_front @Islam Q 进行更改
标签: ios uitableview segue swrevealviewcontroller