View Didload
-(id) initWithName:(NSString*)cateName andDesc:(NSString*)tltName
{
self = [super init];
if(self)
{
self.catName = cateName;
self.titleName = tltName;
}
objArray = [[NSMutableArray alloc] initWithObjects:
[[ListObjects alloc] initWithName:@"Steak" andDesc:@"Rare"],
[[ListObjects alloc] initWithName:@"Steak" andDesc:@"Medium"],
[[ListObjects alloc] initWithName:@"Salad" andDesc:@"Caesar"],
[[ListObjects alloc] initWithName:@"Salad" andDesc:@"Bean"],
[[ListObjects alloc] initWithName:@"Fruit" andDesc:@"Apple"],
[[ListObjects alloc] initWithName:@"Potato" andDesc:@"Baked"],
[[ListObjects alloc] initWithName:@"Potato" andDesc:@"Mashed"],
[[ListObjects alloc] initWithName:@"Bread" andDesc:@"White"],
[[ListObjects alloc] initWithName:@"Bread" andDesc:@"Brown"],
[[ListObjects alloc] initWithName:@"Hot Dog" andDesc:@"Beef"],
[[ListObjects alloc] initWithName:@"Hot Dog" andDesc:@"Chicken"],
[[ListObjects alloc] initWithName:@"Hot Dog" andDesc:@"Veggie"],
[[ListObjects alloc] initWithName:@"Pizza" andDesc:@"Pepperonni"],
nil ];
cellForRowAtIndexPath
static NSString *CellIdentifier = @"Cell";
ThumbCellView *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell = [[ThumbCellView alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil imageName:objArray width:self.view.bounds.size.width];
cell.backgroundColor=[UIColor clearColor];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
ListObjects Class
{
self = [super init];
if(self)
{
self.catName = cateName;
self.titleName = tltName;
}
return self;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier imageName:(NSArray *)imageList width:(int)width
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
}
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
int val;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
if (width==320)
val=0;
else
val=25;
}
else
{
if (width==768)
val=0;
else
val=25;
}
for (int i=0;i<[imageList count];i++)
{
UIButton* cellBgImg;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
cellBgImg = [[UIButton alloc] initWithFrame:CGRectMake(50+i*140+val, 10, 70, 90)];
}
else
{
cellBgImg = [[UIButton alloc] initWithFrame:CGRectMake(70+i*180+val, 65, 103, 133)];
}
UIImage *img=[UIImage imageNamed:@"image.png"];
[cellBgImg setBackgroundImage:img forState:UIControlStateNormal];
[cellBgImg setTitle:[NSString stringWithFormat:@"%d",i+1] forState:UIControlStateNormal];
cellBgImg.titleLabel.font=[UIFont fontWithName:@"Arial" size:0.0];
cellBgImg.tag=i;
[cellBgImg addTarget:self action:@selector(btnpress:) forControlEvents:UIControlEventTouchUpInside];
cellBgImg.backgroundColor=[UIColor clearColor];
[self addSubview:cellBgImg];
}
return self;
}
No comments:
Post a Comment