在View
中使用ViewController
实施segment control
和ViewController
是否有任何解决方案?
我尝试创建ChildViewController
并添加它。当我想查看其他View
时,我尝试使用View
移除removeFromsuperview
并移除ChildViewController
但是它无效。
- (IBAction)segmentcontrol:(id)sender {
notificationsViewController *notification=[[notificationsViewController alloc]init];
if (self.segmentControl.selectedSegmentIndex == 0)
{
if(self.view==nil)
{
self.attendeesTableView.frame=CGRectMake(0, 64, 320, 416);
[self.view addSubview:self.attendeesTableView];
}
else
{
[notification willMoveToParentViewController:nil];
[notification.view removeFromSuperview];
[notification removeFromParentViewController];
self.attendeesTableView.hidden=NO;
}
}
else if(self.segmentControl.selectedSegmentIndex == 1)
{
self.attendeesTableView.hidden = YES;
notification.view.frame=CGRectMake(0, 64, 320, 416);
[self addChildViewController:notification];
[self.view addSubview:notification.view];
[notification didMoveToParentViewController:self];
}
}