开发者

stacking two UITableViews in a single view programmatically?

开发者 https://www.devze.com 2023-04-01 04:01 出处:网络
i\'d like to stack two UITableViews in a single view.i can do this in interface builder, however, i would like to do this programmatically in code.

i'd like to stack two UITableViews in a single view. i can do this in interface builder, however, i would like to do this programmatically in code.

in my main UIViewController, i create two UITableViewControllers in my viewDidLoad method. i thought at first i could do this b开发者_开发知识库y:

[self.view addSubView:controller1.view];
[self.view addSubView:controller2.view];

but this only shows the 2nd view. i've also tried:

[self.view addSubview:controller1.view];
[controller1.view addSubview:controller2.view];

but it still doesn't do what interface builder did above.

UPDATE

i want to accomplish this:

two table views

which i did in interface builder:

xib

but in code.


What is the reason to create two UITableViewControllers? Simply create two UITableView objects and manipulate them.


Overlapped? Did you set their frame different, in order to see them?


controller1.view.frame = CGRectMake(0,0,320,75);
controller2.view.frame = CGRectMake(0,75,320,385);

In a rectangle the values are measured from the upper left corner: x,y,w,h.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号