Ios 如何将tableView中的行链接到序列
我有两个ViewController,ViewController和TableViewController。ViewController有一个按钮,按下时TableViewController将启动。TableViewController包含5行 我想做的是,当我只按偶数行时,我应该返回ViewController。为了解决这个问题,我们可以使用unwindSegue,但我不知道如何让segue响应表中的偶数行 请让我知道如何在表中创建一行链接到segue 下面是TableViewController的代码 代码:Ios 如何将tableView中的行链接到序列,ios,objective-c,segue,uistoryboardsegue,unwind-segue,Ios,Objective C,Segue,Uistoryboardsegue,Unwind Segue,我有两个ViewController,ViewController和TableViewController。ViewController有一个按钮,按下时TableViewController将启动。TableViewController包含5行 我想做的是,当我只按偶数行时,我应该返回ViewController。为了解决这个问题,我们可以使用unwindSegue,但我不知道如何让segue响应表中的偶数行 请让我知道如何在表中创建一行链接到segue 下面是TableViewControl
#import "TableViewController.h"
@interface TableViewController ()
@property NSArray *tableData;
@end
@implementation TableViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.tableData = [NSArray arrayWithObjects:@"Android",
@"iOS",
@"swift",
@"objective-c",
@"openCV",nil];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:
(NSInteger)section {
return [self.tableData count];
}
-(UITableViewCell *) tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [self.tableData objectAtIndex:indexPath.row];
cell.imageView.image = [UIImage imageNamed:@"images.jpg"];
return cell;
}
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:
(NSIndexPath *)indexPath {
NSLog(@"%li", indexPath.row);
NSLog(@"%@", [self.tableData objectAtIndex:indexPath.row]);
}
@end
您可以在中调用PerformsgueWithIdentifierdidSelectRowAtIndexPath@ReinierMelian但是我无法将tableview链接到exit图标来创建一个Unwindsegue在ViewController和destinationViewController之间创建一个segue并放置一个标识您甚至不需要unwind segue,只需弹出或关闭当前控制器即可@TejaNandamuri你能提供代码吗
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:
(NSIndexPath *)indexPath {
if(indexPath.row % 2 == 0) {
// Even row...
}
}