in my app i have a table view and i am adding 4 image view to the first row of my table view .Now i want to add the image view to the next row.How can i do that in the existing code please help.I am posting my part of code:–
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = nil;
static NSString *AutoCompleteRowIdentifier = @"AutoCompleteRowIdentifier";
cell = [tableView dequeueReusableCellWithIdentifier:AutoCompleteRowIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:AutoCompleteRowIdentifier] autorelease];
UIImageView * imageView1 = [[[UIImageView alloc] initWithFrame:CGRectMake(25, 4, 80, 80)] autorelease];
UIImageView * imageView2 = [[[UIImageView alloc] initWithFrame:CGRectMake(115,4,80, 80)] autorelease];
UIImageView * imageView3 = [[[UIImageView alloc] initWithFrame:CGRectMake(205,4, 80, 80)] autorelease];
UIImageView * imageView4 = [[[UIImageView alloc] initWithFrame:CGRectMake(295,4, 80, 80)] autorelease];
UIImageView * imageView5 = [[[UIImageView alloc] initWithFrame:CGRectMake(25, 4, 80, 80)] autorelease];
UIImageView * imageView6 = [[[UIImageView alloc] initWithFrame:CGRectMake(115,4,80, 80)] autorelease];
int j=0;
imageView1.tag = j;
imageView2.tag = j+1;
imageView3.tag = j+2;
imageView4.tag = j+3;
imageView5.tag = j+4;
imageView6.tag = j+5;
[cell.contentView addSubview:imageView1];
[cell.contentView addSubview:imageView2];
[cell.contentView addSubview:imageView3];
[cell.contentView addSubview:imageView4];
[cell.contentView addSubview:imageView5];
[cell.contentView addSubview:imageView6];
}
for ( int i = 1; i <= j; i++ ) {
imageView = (UIImageView *)[cell.contentView viewWithTag:i];
imageView.image = nil;
}
int photosInRow;
if ( (indexPath.row < [tableView numberOfRowsInSection:indexPath.section] - 1) || ([sentence count] % 4 == 0) ) {
photosInRow = 4;
} else {
photosInRow = [sentence count] % 4;
}
for ( int i = 1; i <=[sentence count]; i++ ){
imageView = (UIImageView *)[cell.contentView viewWithTag:i];
[self setImage1:imageView];
}
return cell;
}
I want mu imageView 5 and 6 to be in next row.Please help.How to do it?i am ramming my head against the wall looking for this.
Thanks,
Christy
you can try some thing like bellow … you basically check the present row number then build your required logic …