现在几天我一直在努力使用 UISplitViewControllers,这是我的问题:我有一个主视图,声明如下
#import <UIKit/UIKit.h>
#import "DetailViewController.h"
@class DetailViewController;
@interface MasterViewController : UITableViewController {
NSMutableArray *title, *subTitle;
unsigned int quantity;
}
@property (strong, nonatomic) DetailViewController *detailViewController;
@end
在 master 的 .m 文件中,一切正常(我能够从 sqlite db 填充表并按行显示内容)。当涉及到一行并在右侧填充详细视图时,什么也不会发生。这是行选择:
- (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];
}
简而言之:选择一行后,细节没有注意到任何变化。有什么帮助吗?