How to create a table as shown below
I created a TableView (Grouped Table View). And I can list the items in the table view. But I want to know how the bottom table is displayed
Like the Calendar on the left and the Gregorian on the right? How is this Gregorian displayed on the right side? Is this a Custom TableView, can anyone help me achieve this?
source to share
These are the usual cells with style = UITableViewCellStyleValue1
as well accessoryType = UITableViewCellAccessoryDisclosureIndicator
.
To do it programmatically:
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"YourIdentifier"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
(Note that in real life you will probably try dequeueReusableCellWithIdentifier:
, and only create a new cell if it returns zero.)
Or, if you are working with IB, set Style to Correct Part and Accessory to Exposure Indicator.
source to share
You need to use the following code to help you
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
UIImageView *v = [[[UIImageView alloc] init]autorelease];
v.backgroundColor = [UIColor clearColor]; // put clear color
[v setClipsToBounds:YES];
cell.selectedBackgroundView = v;
[cell setClipsToBounds:YES];
}
UIImageView *imgVBG=(UIImageView*)[cell selectedBackgroundView];
if(indexPath.row==0){
imgVBG.image=[UIImage imageNamed:@"TopImg.png"];
} else if((indexPath.section==0 && indexPath.row==4)||(indexPath.section==1 && indexPath.row==7)){
imgVBG.image=[UIImage imageNamed:@"BottomImg.png"];
} else {
imgVBG.image=[UIImage imageNamed:@"MiddleImg.png"];
}
}
source to share