简体   繁体   中英

Tableview not able to see all rows

I have a view where a calendar takes up the top half of the view and a tableview takes up the second half. I added both of these progmatically. It is a leave/vacation application wherein user submits leave requests from calendar and it appears as a row in the tableview. The problem is if the user goes on submitting leave requests I am not able to see bottom rows of table view and click on them. I tried putting a scroll view but to no use. How should I go about this?

// calendar view instance

calendarView = [[[KLCalendarView alloc] initWithFrame:CGRectMake(0.0f, 50.0f,  768.0f, 1024) delegate:self] autorelease];

//tableview instance

myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,690,768,1024) style:UITableViewStyleGrouped];

// add to main view

[self.view addSubview:calendarView];
[self.view addSubview:myTableView];

[self.view bringSubviewToFront:myTableView];

You init both Views (Calendar and Table) with the sizes 768 x 1024! You dont have an display that show 768 x 2048 px! Reduce the size of both Views to the max (iPhone/iPad)-Height / 2. Than you should see all Views complete.

The problem is your tableview frame. Find what is the available space you have in both orientation and set it for the tableview. It will solve your problem.

I suppose this is iPad targeted. The 4th parameter to CGRectMake is height. Try doing

CGRectMake(0,690,768,1024-690)

Same with the calendar view.

You have to set the contentSize of the table to make it scrollable, in case the total size is bigger than the frame you put in initWithFrame.

Try setting this:

myTableView.contentSize = CGSizeMake (x, y)

Where y can be the TOTAL height of your table

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM