I'm now building up an iPad app which uses UISplitViewController
and on the detail view controller I want to initialize two UITableView
. However, for some strange reasons even if I tried to initialize those two table views in the same way, only the second table view is initialized properly.
Here's my code that initializes the table views:
_t1 = [[UITableView alloc] initWithFrame:CGRectMake(30, 400, 300, 600)];
_t1.delegate = self;
_t1.datasourse = self;
[self.view addSubview:_t1];
_t2 = [[UITableView alloc] initWithFrame:CGRectMake(360, 400, 300, 600)];
_t2.delegate = self;
_t2.datasourse = self;
[self.view addSubview:_t2];
I set those two table views as @property (strong, nonatomic)
in my header file of the view controller. I don't think I've made any mistakes so far.
However, here's the image of the resultant detail view controller. The first table view starts populating its cells after some space is filled at the top of the table view. It looks like the redundant space's height is same to the height of the navigation bar, but when I tried to output self.view
before the addSubview:
method on the above code, I got the same result saying self.view = <UIView: 0x10a3dd920; frame = (0 0; 768 1024); autoresize = W+H; layer = <CALayer: 0x10a3dd800>>
. So, I think it's added to the same parent view.
So what am I missing? And how can I fix the issue up? I suspect it's related to either navigation controller or split view controller, but am not sure.
I use iOS 7.1 and Xcode 5.1.