2012-10-16 27 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

相關問題