【问题标题】:Prototype cell does not navigate push to next view controller Storyboard原型单元不导航推送到下一个视图控制器故事板
【发布时间】:2017-12-01 03:03:06
【问题描述】:

我使用情节提要创建了单视图应用程序。 我有 viewcontoller.h 文件

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController<UITableViewDelegate, UITableViewDataSource>


@end

我有 viewcontoller.m 文件

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
{
    NSArray *recipes;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    recipes = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto", @"Full Breakfast", @"Hamburger", @"Ham and Egg Sandwich", @"Creme Brelee", @"White Chocolate Donut", @"Starbucks Coffee", @"Vegetable Curry", @"Instant Noodle with Egg", @"Noodle with BBQ Pork", @"Japanese Noodle with Pork", @"Green Tea", @"Thai Shrimp Cake", @"Angry Birds Cake", @"Ham and Cheese Panini", nil];
}
-(NSInteger)tableView :(UITableView *)tableView numberOfRowsInSection :(NSInteger)section
{
    return [recipes count];

}
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *simpleTableIdentifier=@"RecpieCell";
    UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
    if(cell ==nil)
    {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
    }

    cell.textLabel.text=[recipes objectAtIndex:indexPath.row];
    return cell;

}

@end

在故事板文件中,我有三个视图控制器

1-导航控制器 2-食谱书视图控制器 3-视图 控制器

Recipe Book View Controller 的 table view 的原型单元通过 push segue 连接到 View Controller。问题是 Recipe Book View Controller 没有导航到 View Controller 吗?

enter image description here

enter image description here

【问题讨论】:

  • 您的屏幕截图未显示 tableview 行的操作;如果您选择“Table View Cell”,则 segue 应链接到检查器中的“动作”。是这样吗?
  • 点击单元格时你想导航到 Viewcontroller 吗?
  • 是的...从这个链接您可以下载样本以进行更正dropbox.com/s/kpybdmtov7i0wne/RecipeBook.zip?dl=0

标签: ios objective-c uitableview storyboard


【解决方案1】:

只需进行手动转场。你知道怎么做吗? ctrl 从一个视图控制器拖动到另一个。给它一个标识符。

然后重写函数“didSelectRowAt indexPath”。在那里,调用 performSegue。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-24
    • 2015-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多