Reputation: 1236
I have created a TableView(Grouped Table View). And I can list the items in the table view. But I want to know how the below table is displayed
Like Calender is in the left side, and Gregorian in the Right Side ?? How that Gregorian is displayed in the Right Side ?? Is it a Custom TableView, Can anyone help me how to achieve that ?
Upvotes: 3
Views: 1770
Reputation: 16864
You need to use following code helping to 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"];
}
}
Upvotes: 1
Reputation: 12780
Here is your answer UITableViewCell with UITableViewCellStyleValue1, adding new line to detailTextLabel at cell at bottom
Upvotes: -2
Reputation: 16725
Those are just regular cells with style = UITableViewCellStyleValue1
and also accessoryType = UITableViewCellAccessoryDisclosureIndicator
.
To make one programmatically:
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"YourIdentifier"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
(Note that in real life you would probably try to dequeueReusableCellWithIdentifier:
, and only create a new cell if that returns nil.)
Or, if you're working with IB, set "Style" to "Right Detail" and "Accessory" to "Disclosure Indicator".
Upvotes: 10