[英]Custom UITableViewController inside Container View: NSInternalInconsistencyException
我試圖在Container View
內插入自定義UITableViewController
。 容器視圖放置在靜態UITableView的單元格內,如下圖所示。
我只想要一種在同一屏幕中將靜態單元與動態單元組合的方法。
在Identity Inspector
當“ 類 ”字段為空(即標准UITableViewController)時,它將在單元格內部顯示一個空的動態表。 但是,當我在該字段中輸入我的自定義類名稱(擴展了UITableViewController)時,我得到了NSInternalInconsistencyException
:
[UITableViewController loadView] loaded the "Enx-aT-Rum-view-zY2-9U-Z6d" nib but didn't get a UITableView.
這些是MyCustomUITableViewController的內容:
@implementation MyCustomUITableViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 2;
}
@end
我必須承認,我仍然不了解Container View背后的所有邏輯,但我只想在其中僅顯示一個視圖(不進行任何交換或其他操作)。
任何幫助,將不勝感激,謝謝!
在把頭撞到桌子上好幾個小時后,我設法解決了這個問題。 我不得不分配/初始化MyCustomUITableViewController的tableview。 我重寫MyCustomUITableViewController的loadView
方法:
- (void) loadView{
self.tableView = [[UITableView alloc]init];
}
很高興去!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.