@August: I took your advice and added the UIButtons as subviews of the UIView rather than look further into the UITable. Thanks!
Hopefully the code below will help to jumpstart someone else. I've statically placed 4 buttons in a grid. It shouldn't be much harder to place any number of buttons according to the parent UIView's bounds and orientation.
@implementation IconView
- (id)initWithFrame:(struct CGRect)windowRect{
self = [super initWithFrame: windowRect];
if (self != nil){
for(int i = 0; i < 4; i++){
buttons[i] = [self buildButton];
[self addSubview: buttons[i]];
}
[self reInit];
}
return self;
}
- (UIButton *) buildButton{
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 60, 60)];
[button setBackgroundImage: [[UIImage imageNamed:@"icon.png"] stretchableImageWithLeftCapWidth:60 topCapHeight:0] forState:UIControlStateNormal];
return [button autorelease];
}
- (void)reInit{
CGRect rect;
rect = buttons[0].frame;
rect.origin = CGPointMake(5, 5);
buttons[0].frame = rect;
rect = buttons[1].frame;
rect.origin = CGPointMake(70, 5);
buttons[1].frame = rect;
rect = buttons[2].frame;
rect.origin = CGPointMake(5, 70);
buttons[2].frame = rect;
rect = buttons[3].frame;
rect.origin = CGPointMake(70, 70);
buttons[3].frame = rect;
}
@end