missNotesのプロフィール

@missNotes missNotes
ありがとう数2
質問数1
回答数1
ベストアンサー数
1
ベストアンサー率
100%
お礼率
100%

  • 登録日2013/08/07
  • objective-cでUIButtonを作成後

    xcodeのobjective-cで書いています。 UIButtonをプログラムで複数生成し、 その後別のボタンを作成し、そのボタンを押したら任意のボタンを削除(隠すのではなく)する方法を模索しています。 @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. for (int i = 0; i < 5; i++) { UIButton *bt = [UIButton buttonWithType:UIButtonTypeRoundedRect]; bt.frame = CGRectMake(20.0f, 20.0f + (i * 25), 20.0f, 20.0f); bt.tag = i; [bt addTarget:self action:@selector(pushBt:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:bt]; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBAction)pushBt:(UIButton *)sender { [sender removeFromSuperview]; } 押したボタンを消す事はできるようなのですが、 一度に全て消す、tagの1と2を消す等の方法や考え方などご教授お願いします。