UITabBar 和獨立的 UItableView 問題?这个有关问题俺也遇到了
用TabView時,每一個Tab各自獨立指定xib,碰到 TableView不知道為甚麼就是有問題
現在 mainwindow 在 IB 大概是這樣:
Tab Bar Controller
|-Navigation Controller
|-Navigation Controller
...
|-Navigation Controller
|-Navigation Bar
|-View Controller(NIB name 設定成 MyTableView)
|-Navigation Item
|-Tab Bar Item
MyTableView是:
|-File's Owner (指定 MyTableViewController)
|-View
|-TableView(DataSource 和 Delegate 指向 Files's Owner)
MyTableViewController:UIViewController <UITableViewDelegate, UITableViewDataSource>
然後寫了
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
三個函數
執行時卻出現這個例外:
** -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x25329f0
都已經定義了,不知道為甚麼有這錯誤
如果不分開,都寫在 MainWindow就可以
麻煩大家解答了, thanks
解决方法
|-View Controller(NIB name 設定成 MyTableView) 這裡要指定 class