請按照下列步驟。
1)用xib創建一個tableViewController。 2)創建只有兩個其他xib的截圖如下: -
3)從對象窗口拖動uitableView。
![enter image description here](https://i.stack.imgur.com/SlI41.png)
4)改變其類,你首先創建TableViewController的類。
5)將文件所有者的視圖委託連接到tableView。
6),並使用代碼------
- (void)viewDidLoad
{
MYViewController *FirstTableController=[[MYViewController alloc] initWithNibName:@"MYViewController" bundle:nil];
MYViewController *secondTableController=[[MYViewController alloc] initWithNibName:@"MYSecondController" bundle:nil];
MYViewController *thirdTableController=[[MYViewController alloc] initWithNibName:@"MYThird" bundle:nil];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
![enter image description here](https://i.stack.imgur.com/iffVN.png)
或者
#import <UIKit/UIKit.h>
@interface MYViewController : UITableViewController
{
IBOutlet UITableView *f_table,*s_table,*t_table; //outlets for different tableViews in xib.
}
@end
![enter image description here](https://i.stack.imgur.com/POuAS.png)
- (void)viewDidLoad
{
[super viewDidLoad];
self.view=f_table; // when working with first table.
self.view=s_table; //working with second table.
self.view=t_table; //working with third table.
}
在視圖控制器中,如果viewController初始化爲tableview控制器,請檢查我的問題代碼。感謝您的回覆 – sudheer
確定等待 – Warewolf