I want to create calendar view with UITableView
I want to have 4 square in each rows like the below picture:
would you please help me, how can I have 4 squ
Try out this code:-
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero] autorelease];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
int column = 4;
for (int i=0; i<column; i++) {
UIImageView *aBackgroundImageView = [[UIImageView alloc]initWithFrame:CGRectMake(32+184*i,10, 167,215)];
aBackgroundImageView.tag = (column*indexPath.row)+i;
[cell.contentView addSubview:aBackgroundImageView];
[aBackgroundImageView release];
}
return cell;
}
Column will number of items you want in one cell.
If you want to create a calendar view, check out this code for some ideas (depending on what you want to achieve).
To create a UITableView
row with four equally sized cells, just implement the tableView:cellForRowAtIndexPath:
datasource method to create a view with e.g. four equally sized UILabel
s.