static NSString *CellIdentifier = @"Cell";
tblcell = (tablecellView*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (tblcell == nil)
{
NSArray *outlets;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
outlets = [[NSArray alloc] initWithArray:[[NSBundle mainBundle] loadNibNamed:@"tablecellView" owner:nil options:nil] ] ;
}
else
{
outlets = [[NSArray alloc] initWithArray:[[NSBundle mainBundle] loadNibNamed:@"tablecellView_ipad" owner:nil options:nil] ] ;
}
for (id currentObject in outlets)
{
if ([currentObject isKindOfClass:[UITableViewCell class]])
{
tblcell = (tablecellView *) currentObject;
break;
}
}
}
i = indexPath.row*4;
if (i < [imagearray count])
{
tblcell.viewa.hidden=FALSE;
tblcell.viewa.layer.borderColor = [UIColor colorWithRed:191.0f/255.0f green:191.0f/255.0f blue:191.0f/255.0f alpha:1.0f].CGColor;
tblcell.viewa.layer.borderWidth=1.0f;
NSURL *urla;
urla = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[imagearray objectAtIndex:i]]];
[tblcell.imga setImageWithURL:urla placeholderImage:[UIImage imageNamed:@"ncam.png"]];
[tblcell.btna.titleLabel setText:[NSString stringWithFormat:@"%d",i]];
[tblcell.btna addTarget:self action:@selector(btnimage:) forControlEvents:UIControlEventTouchUpInside];
}
i++;
if (i < [imagearray count])
{
tblcell.viewb.hidden=FALSE;
tblcell.viewb.layer.borderColor = [UIColor colorWithRed:191.0f/255.0f green:191.0f/255.0f blue:191.0f/255.0f alpha:1.0f].CGColor;
tblcell.viewb.layer.borderWidth=1.0f;
NSURL *urlb;
urlb = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[imagearray objectAtIndex:i]]];
[tblcell.imgb setImageWithURL:urlb placeholderImage:[UIImage imageNamed:@"ncam.png"]];
[tblcell.btnb.titleLabel setText:[NSString stringWithFormat:@"%d",i]];
[tblcell.btnb addTarget:self action:@selector(btnimage:) forControlEvents:UIControlEventTouchUpInside];
}
i++;
if (i < [imagearray count])
{
tblcell.viewc.hidden=FALSE;
tblcell.viewc.layer.borderColor = [UIColor colorWithRed:191.0f/255.0f green:191.0f/255.0f blue:191.0f/255.0f alpha:1.0f].CGColor;
tblcell.viewc.layer.borderWidth=1.0f;
NSURL *urlc;
urlc = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[imagearray objectAtIndex:i]]];
[tblcell.imgc setImageWithURL:urlc placeholderImage:[UIImage imageNamed:@"ncam.png"]];
[tblcell.btnc.titleLabel setText:[NSString stringWithFormat:@"%d",i]];
[tblcell.btnc addTarget:self action:@selector(btnimage:) forControlEvents:UIControlEventTouchUpInside];
}
i++;
if (i < [imagearray count])
{
tblcell.viewd.hidden=FALSE;
tblcell.viewd.layer.borderColor = [UIColor colorWithRed:191.0f/255.0f green:191.0f/255.0f blue:191.0f/255.0f alpha:1.0f].CGColor;
tblcell.viewd.layer.borderWidth=1.0f;
NSURL *urld;
urld = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[imagearray objectAtIndex:i]]];
[tblcell.imgd setImageWithURL:urld placeholderImage:[UIImage imageNamed:@"ncam.png"]];
[tblcell.btnd.titleLabel setText:[NSString stringWithFormat:@"%d",i]];
[tblcell.btnd addTarget:self action:@selector(btnimage:) forControlEvents:UIControlEventTouchUpInside];
}
i++;
return tblcell;
}
==============行数
if (tableView == GridTableview)
{
return (imagearray.count/4)+1;
}