1

我有一个使用情节提要的项目。我有一个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 链接到UITableViewControllersegue

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{

    if([[segue identifier] isEqualToString:@"Records"]){

        ResultTableViewController *cvc = (ResultTableViewController *)[segue destinationViewController];
    }
}

但它并没有改变这一点。我该如何切换这个UITableViewController?感谢所有帮助。

4

1 回答 1

2

如果我对您的理解正确,并且您只想在选择第一个表格中的单元格时推送一个新的表格视图控制器,那么您所缺少的就是您需要拥有

[self performSegueWithIdentifier:@"Records"]; 

在您的 tableView didSelectRowAtIndexPath 方法中。

于 2012-05-09T18:34:53.150 回答