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;
}
答案 0 :(得分:0)
答案 1 :(得分:0)
您必须使用UITolView的UICollectionView。以下显示的链接可以帮助您解决此问题 - &gt;
http://www.appcoda.com/ios-programming-uicollectionview-tutorial/
http://skeuo.com/uicollectionview-custom-layout-tutorial
http://mobile.tutsplus.com/tutorials/iphone/uicollectionview-layouts/
http://adoptioncurve.net/archives/2012/09/a-simple-uicollectionview-tutorial/
http://maniacdev.com/2012/09/tutorial-how-to-create-an-ios-6-uicollectionview-using-storyboards/
所有最好的......