我有一个关于为什么我的 UITableView 不会加载 detailView 的问题......我以前用界面构建器做过,但现在我只是想纯粹地以编程方式来做。
在我的 tableView.h 中:
@property (strong, nonatomic) RLCASearchDetailViewControllerViewController *searchDetailViewController;
在我的 tableView.m 中:
@synthesize searchDetailViewController = _searchDetailViewController;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (!self.searchDetailViewController)
{
self.searchDetailViewController = [[RLCASearchDetailViewControllerViewController alloc] initWithNibName:@"" bundle:nil];
}
SearchItem *item = [ content objectAtIndex:indexPath.row ];
[self.navigationController pushViewController:self.searchDetailViewController animated:YES];
self.searchDetailViewController.detailItem = item;
}
顺便说一句,我尝试将 initWithNibName: 值设为 nil,空字符串如上,甚至 @"RLCASearchDetailViewControllerViewController"。没有任何作用...
在我的 RLCASearchDetailViewControllerViewController.h 中:
@interface RLCASearchDetailViewControllerViewController : UIViewController
{
SearchItem *detailItem;
}
@property (strong, nonatomic) id detailItem;
@end
在我的 RLCASearchDetailViewControllerViewController.m 中:
@synthesize detailItem = _detailItem;
- (void)setDetailItem:(SearchItem*)newDetailItem
{
NSLog( @"GETS HERE" );
if (_detailItem != newDetailItem) {
_detailItem = newDetailItem;
// Update the view.
[self configureView];
}
}
- (void)configureView
{
// Update the user interface for the detail item.
if (self.detailItem)
{
NSLog( @"GETS HERE" );
}
}
- (void)loadView
{
[super loadView];
// If you create your views manually, you MUST override this method and use it to create your views.
// If you use Interface Builder to create your views, then you must NOT override this method.
NSLog( @"DOES NOT GET HERE" );
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSLog( @"DOES NOT GET HERE" );
}
如上所示,当我实现了一些调试打印时......它在理论上做了它应该做的事情,但由于某种原因没有加载视图。当单击表格单元格时,当视图应更改为子视图时,这会在 GUI 中体现出来。
我究竟做错了什么?请帮助......这让我发疯了,我已经在互联网上翻找了一段时间,希望得到答案。
非常感谢 - 我真的很感激!;)
真诚的,彼得。