【发布时间】: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 吗?
【问题讨论】:
-
您的屏幕截图未显示 tableview 行的操作;如果您选择“Table View Cell”,则 segue 应链接到检查器中的“动作”。是这样吗?
-
点击单元格时你想导航到 Viewcontroller 吗?
-
是的...从这个链接您可以下载样本以进行更正dropbox.com/s/kpybdmtov7i0wne/RecipeBook.zip?dl=0
标签: ios objective-c uitableview storyboard