Reputation: 101
i have two UIViewController
, A & B
[A addSubView: B.view];
it's ok.
but i got an question, i can't get the B's UIButton
Touch Event after [A addSubView: B.view]
why?
is anyone can help me thank you~
Here's my some code :
A View:
CellAction_ViewController *cellActionViewController = [[CellAction_ViewController alloc] initWithNibName:@"CellAction_ViewController" bundle:nil];
[cell.contentView addSubview:cellActionViewController.view];
[cellActionViewController.button_like addTarget:self
action:@selector(Likes_Button:)
forControlEvents:UIControlEventTouchUpInside];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
B View:
- (void)viewDidLoad {
[super viewDidLoad];
// bala bala ...
[_button_like setClipsToBounds:YES];
}
Upvotes: 1
Views: 326
Reputation:
It will Work.... Instead of [A.view addSubview:B.view];
Use this
[A addChildViewController:B];
[B didMoveToParentViewController:A];
Because your are adding A ViewController subview.It should be A ViewController's views sub view.
Upvotes: 2