Iphone 无法导航到UITableView中的详细信息视图

Iphone 无法导航到UITableView中的详细信息视图,iphone,ios,uitableview,ios6,Iphone,Ios,Uitableview,Ios6,我试图在UITableView中导航到细节视图,但在执行时似乎遇到了一些问题 我的代码: ViewController.h #import <UIKit/UIKit.h> #import "SecondViewController.h" @interface ViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>{ NSArray *tableItems;

我试图在UITableView中导航到细节视图,但在执行时似乎遇到了一些问题

我的代码:

ViewController.h

#import <UIKit/UIKit.h>
#import "SecondViewController.h"

@interface ViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>{
    NSArray *tableItems;
    NSArray *images;

}

@property (nonatomic,retain) NSArray *tableItems;
@property (nonatomic,retain) NSArray *images;

@end
#import <UIKit/UIKit.h>

@interface SecondViewController : UIViewController{
    IBOutlet UILabel *lbl;
}

-(void) printRowNumber:(int)num;

@end
我能够打印输出中indexPath.row的值,但无法显示SecondViewController的detailview。不知道问题出在哪里。需要一些指导…谢谢..

看看这个:

如果要使用
pushViewController:
方法,则需要将
mainViewController
嵌入到
NavigationController


如果您不想使用
NavigationController
,则可以使用
presentViewController:
方法加载
detailViewController
,并使用
dismissViewController:
方法返回
mainViewController

是否收到任何错误?点击表格行时会发生什么情况?没有错误,我可以打印indexPath.row的值,但我无法进入detailview…只是为了确认-您确定主viewcontroller嵌入到导航控制器中了吗?没有。。。它不嵌入导航控制器中。怎么做?你不能使用基于视图的应用程序吗?
#import <UIKit/UIKit.h>

@interface SecondViewController : UIViewController{
    IBOutlet UILabel *lbl;
}

-(void) printRowNumber:(int)num;

@end
#import "SecondViewController.h"

@interface SecondViewController ()

@end

@implementation SecondViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void) printRowNumber:(int)num{
    lbl.text = @"Hello";
    NSLog(@"%d",num);
}
@end