我有一个使用故事板的项目。我有一个UIView
,我在视图底部放置了一些图像和按钮,我放置了UITableView
。我将此代码放在UIView.h
。
interface MenuViewController : UIViewController<UITableViewDelegate, UITableViewDataSource>
{
IBOutlet UITableView *MenuTable;
NSMutableArray *TabloMenu;
id menuler;
}
@property (nonatomic, retain) IBOutlet UITableView *MenuTable;
@property (nonatomic, retain) NSMutableArray *TabloMenu;
在iuview.m
:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)table {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [TabloMenu count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"CellFirmalar";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
menuler = [TabloMenu objectAtIndex:[indexPath row]];
cell.textLabel.text = [menuler objectForKey:@"Tanim"];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *alertString = [NSString stringWithFormat:@"Clicked on row #%d", [indexPath row]];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:alertString message:@"" delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil];
[alert show];
}
直到这里一切运转良好。当我单击单元格行号时,数据即将到来。
我在故事板上添加了新的UITableViewController
,并将链接的tableview链接到UITableViewController
以获取segue
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([[segue identifier] isEqualToString:@"Records"]){
ResultTableViewController *cvc = (ResultTableViewController *)[segue destinationViewController];
}
}
但它没有改变这一点。我该如何切换UITableViewController
?感谢您的帮助。
答案 0 :(得分:2)
如果我理解正确并且您只想在选择第一个表格中的单元格时推送新的表格视图控制器,那么您所缺少的就是您需要
[self performSegueWithIdentifier:@"Records"];
在你的tableView didSelectRowAtIndexPath方法中。