开发者

How to create a table in a view ( I dont want the table to cover up my entire screen)

Is there any way out .., that I can create a UITableView in a view such that it doesn cover up entire the screen... For example :

I want the first half of th开发者_如何学运维e screen to be a UITextView and the next half portion of my screen to be a UITableView.. Thanks in advance


CGRect cgRct = CGRectMake(0, 50, 320, 250);  
UITableView *tableView1 = [[UITableView alloc] initWithFrame:cgRct style:UITableViewStylePlain];  
    //tableView.editing = YES;  
    tableView1.dataSource = self;  
    tableView1.delegate = self;  
    tableView1.backgroundColor=[UIColor clearColor];  
[self.view addSubview:tableView1];


You are probably creating a UITableViewController for your tableView and then realizing that you can't change the size of the tableView. Am I right? If that is the case then don't create a UITableViewController, just create a normal UIViewController and than add your tableView using Interface Builder or the code which other people posted here.


In Interface Builder (if you are using it), just drag-drop a UITableView to your UIView and adjust its width, height and y position in the Inspector.

If you are programmatically creating the view, change the frame of the UITableView

CGRect tablefrm = [tableViewObject frame];
tablefrm.origin.y = 240.0f //new origin
tablefrm.size.height = 240.0f; //new height
[tableViewObject setFrame:tablefrm]; //assuming already added the tableview to the view.
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜