2012-10-16 63 views
0

我甚至不知道我是否正确执行此操作,但这是我正在尝试执行的操作。我有一个包含一个表格视图的故事板 - 以编程方式填充 - 所有这些都可以工作。我还在故事板中有另一个ViewController,它基本上将显示在表格视图中选择的任何细节。故事板中的表格视图和详细视图之间没有任何间隔 - 是否应该有? - 我创建了一个类来处理这个细节视图。故事板&'NSInternalInconsistencyException',原因:'无法加载捆绑中的NIB:'NSBundle

所以我有这个在我的detailViewController.h

#import <UIKit/UIKit.h> 

@class Profile; 

@interface MedStaffDetailViewController : UIViewController 

@property (weak, nonatomic) IBOutlet UIImageView *profileImage; 

@property (weak, nonatomic) IBOutlet UIBarButtonItem *profileMobile; 

@property (weak, nonatomic) IBOutlet UIBarButtonItem *profilePhone; 

@property (weak, nonatomic) IBOutlet UIBarButtonItem *profileEmail; 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil detail:(Profile *)profile title:(NSString *)title; 


@end 

而这在其实施:

#import "MedStaffDetailViewController.h" 
#import "MedStaffViewController.h" 
#import "Profile.h" 

@interface MedStaffDetailViewController() 

@end 

@implementation MedStaffDetailViewController 
@synthesize profileEmail, profileImage, profileMobile, profilePhone; 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil detail:(Profile *)profile title:(NSString *)title 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
     self.title = title; 

    } 
    return self; 
} 
@end 

我只是想处理一个行的选择在表视图中显示此详细视图与适当的数据 - 当我只是做一个主视图类型的应用程序时,我有这个工作 - 但现在我正在使用一个故事板,所以我可以学习。

我的身份检查的详细视图设置类MedStaffDetailViewController,并在表视图控制器中执行以下:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // Navigation logic may go here. Create and push another view controller. 
    /* 
    <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; 
    // ... 
    // Pass the selected object to the new view controller. 
    [self.navigationController pushViewController:detailViewController animated:YES]; 
    */ 

    _showProfile = [_profileArray objectAtIndex:indexPath.row]; 
    NSLog(@"Selected: %@", [_showProfile lastName]); 

    self.detailViewController = [[MedStaffDetailViewController alloc] initWithNibName:@"MedStaffDetailViewController" bundle:nil detail:_showProfile title:@"This is the title"]; 

    [self.navigationController pushViewController:self.detailViewController animated:YES]; 


} 

所有这一切都建立良好,但引发错误的标题这个问题跑的时候。我应该 - 还是我 - 需要在故事板中创建一个seque?我将如何获取该细节视图以显示何时选中某一行。

回答

2

你可以使用:

UIStoryboard* sb = [UIStoryboard storyboardWithName:@"mystoryboard" bundle:nil]; 
UIViewController* vc = [sb instantiateViewControllerWithIdentifier:@"MedStaffDetailViewController"]; 
+0

它甚至会更好,说'UIStoryboard * SB = self.storyboard;' –

+0

但我在哪里调用[MedStaffDetailViewController页头] initWithNibName等等,等等等等。 ]。因为这为视图提供了必要的数据。 – CodeMoto

+0

答案很清楚! – juan

相关问题