ボタンを2つ追加して削除するカスタムビューを作成します。
-(UIView *)getNewViewWithTag:(NSInteger)tag{
UIView *containerView = [[UIView alloc] initWithFrame:CGRectMake(0,0,100,100)];//Set appropriate frame
UIButton *addButton = [UIButton buttonWithType:UIButtonTypeCustom];
addButton.frame = CGRectMake(0,0,50,50); //Set appropriate frame
addButton.tag = tag;
[addButton addTarget:self action:@selector(addNewView:) forControlEvents:UIControlEventTouchUpInside];
[containerView addSubview:addButton];
UIButton *deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
deleteButton.frame = CGRectMake(50,0,50,50); //Set appropriate frame
deleteButton.tag = tag;
[deleteButton addTarget:self action:@selector(deleteView:) forControlEvents:UIControlEventTouchUpInside];
[containerView addSubview:deleteButton];
containerView.tag = tag;
return containerView;
}
-(void)addNewView:(id)button{
NSInteger tag = [button tag];
UIView *view = [self getNewViewWithTag:tag+1];
//set appropriate frame
[scrollView addSubview: view];
}
-(void)deleteView:(id)button{
NSInteger tag = [button tag];
UIView *viewToDelete = [scrollView viewWithTag:tag];
[viewToDelete removeFromSuperview];
}
あなたは私が重複質問を見つけるいけない、私はscrollview私は、これは新しい問題だと思う – Matt
@mattを好む必要があります:あなたはこのような何かを行うことができます。 –
@danhを使用する必要が 'UITableView' –