Objective c 在ClearSelectionInviewMillappear上获取错误

Objective c 在ClearSelectionInviewMillappear上获取错误,objective-c,Objective C,我最近将Apple的主详细信息模板复制到了我自己的项目中,但这行代码出现了一个错误: - (void)viewWillAppear:(BOOL)animated { self.clearsSelectionOnViewWillAppear = self.splitViewController.isCollapsed; //ERROR ON THIS LINE it says "Property 'clearsSelectionOnViewWillAppear` not found on obje

我最近将Apple的主详细信息模板复制到了我自己的项目中,但这行代码出现了一个错误:

- (void)viewWillAppear:(BOOL)animated {
self.clearsSelectionOnViewWillAppear = self.splitViewController.isCollapsed; //ERROR ON THIS LINE it says "Property 'clearsSelectionOnViewWillAppear` not found on object type 'MasterViewController *'"
[super viewWillAppear:animated];
}
苹果的模板中没有出现错误。请帮忙

以下是MasterViewController声明:

#import <UIKit/UIKit.h> 
@class DetailViewController; 

@interface MasterViewController : UIViewController 
@property (strong, nonatomic) DetailViewController *detailViewController; 
@property (strong, nonatomic) IBOutlet UITableView *tableView; 
@end
您对MasterViewController的声明未显示ClearSelectionInviewMillAppear属性。这就是为什么你会犯你提到的错误。我的怀疑是,在基于MasterViewController的代码的原始代码中,扩展了UITableViewController或UICollectionViewController,而不是UIViewController。检查原始模板以查看MasterViewController是如何声明的。如果它是Xcode中的标准主细节模板,我相信它应该是UITableViewController


或者,您的代码引用了错误的视图控制器。在不知道所有细节的情况下,我不能肯定地告诉您。

您能发布声明MasterViewController的代码吗?看起来MasterViewController没有ClearSelectionInviewMillAppear属性。通常,该属性用于UICollectionViewController@界面MasterViewController:UIViewController@property strong,非原子DetailViewController*DetailViewController@属性强,非原子IBUITableView*tableView@end ClearSelectionInviewMillAppear是UITableViewController而不是UIViewController的属性。只需打开xcode,然后按new xcode project,选择Master View作为选项。请参阅上面我对答案所做的更改-我相信您需要做的是从UITableViewController扩展MasterViewController。