2013-05-09 57 views
0

它現在幾天我一直在掙扎UISplitViewControllers的,這裏是我的問題:我有聲明如下uisplitviewcontroller:通過選擇行由主到細節

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

@class DetailViewController; 
@interface MasterViewController : UITableViewController { 
    NSMutableArray *title, *subTitle; 
    unsigned int quantity; 
} 

@property (strong, nonatomic) DetailViewController *detailViewController; 
@end 

在主人的主視圖.m文件一切工作正常(我能夠從sqlite數據庫填充表並顯示行中的內容)。當選擇一行並在右側填充詳細視圖時,什麼都不會發生。這裏是行選擇:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    MyObject itemFromDB; 
    /* 

    ... DB stuff here ... 

    */ 

    self.detailViewController.detailItem = itemFromDB; 
} 

這裏的現在DetailViewController實現:

@interface DetailViewController : UIViewController <UISplitViewControllerDelegate> 
@property (strong, nonatomic) MyObject *detailItem; 
@property (weak, nonatomic) IBOutlet UILabel *name, *phone; 
@end 

和細節的.M:

#import "DetailViewController.h" 
@interface DetailViewController() 
- (void)configureView; 
@end 

@implementation DetailViewController 

- (void)setDetailItem:(MyObject *)newItem 
{ 
    if (_detailItem != newItem) { 
     _detailItem = newItem; 
     [self configureView]; 
    } 
} 

- (void)configureView 
{ 
    if (self.detailItem) { 
     self.name.text = [self.detailItem name]; 
     self.phone.text = [self.detailItem phone]; 
    } 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    [self configureView]; 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
} 

在簡單的話:細節沒有注意到有什麼選擇一行後更改。任何幫助?

回答

3

您從未定義過self.detailViewController。你應該這樣做:

self.detailViewController = self.splitViewController.viewControllers [1];

+0

我不敢相信這是一件小事......我真的需要一些睡眠xD非常感謝你;) – n0n4m3 2013-05-09 17:34:28

+0

非常感謝。這是工作。 – RXGangam 2015-11-19 05:26:06