【问题标题】:I need help UITableView on UIView (Storyboard Project)我需要关于 UIView 的 UITableView 帮助(故事板项目)
【发布时间】:2012-05-18 07:25:04
【问题描述】:

我有一个使用情节提要的项目。我有一个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?感谢大家的帮助。

【问题讨论】:

    标签: ios uitableview uiview uistoryboard


    【解决方案1】:

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

    [self performSegueWithIdentifier:@"Records"]; 
    

    在您的 tableView didSelectRowAtIndexPath 方法中。

    【讨论】:

    • “MenuViewController”没有可见的@interface 声明选择器“performSegueWithIdentifier:”
    • 对不起,方法是 performSegueWithIdentifier:sender。
    • 所以调用应该看起来像 [self performSegueWithIdentifier:@"Records" sender:self];
    • :( is not working alert is shown but notswitch 你知道另一种解决方案吗?
    • 你是如何在故事板中设置segue的?它是从表格单元格到下一个视图控制器还是从第一个视图控制器到下一个视图控制器?
    猜你喜欢
    • 2013-08-31
    • 2023-04-06
    • 2012-08-07
    • 2011-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-27
    • 1970-01-01
    相关资源
    最近更新 更多