Reputation: 24892
I have this action for the "Touch Up Inside" event of a UIButton that should create a new UIButton right below the sender:
-(IBAction) cloneMe: (id) sender{
if (!currentY) {
currentY = [sender frame].origin.y;
}
UIButton *clone = [UIButton buttonWithType:UIButtonTypeRoundedRect];
CGRect cloneFrame = [sender frame];
cloneFrame.origin.y += currentY + cloneFrame.size.height + 30;
clone.frame = cloneFrame;
currentY = cloneFrame.origin.y + cloneFrame.size.height;
}
It doesn't work and the new button is never displayed. Anybody knows what's going on?
Upvotes: 1
Views: 493
Reputation: 170829
You create button but don't add it to view hierarchy - you missing
[self.view addSubView: clone];
call or similar
Upvotes: 1