一个controller中加入另外一个controller的view 适用于segment的状况
Posted on 2014-03-26 11:22 cillyfly 阅读(154) 评论(0) 编辑 收藏 举报修正方案,之前的方案方案会导致队列不断增加,这边需要注意的是,当view为nil时 不会调用removeFormSuperView 所以这个时候不会出现异常。队列不断增加会导致内存溢出。
- (void)clickToChose:(id)sender
{
UIButton *button = (UIButton *)sender;
oneViewController *oneView = [self.storyboard instantiateViewControllerWithIdentifier:@"one"];
twoViewController *twoView = [self.storyboard instantiateViewControllerWithIdentifier:@"two"];
switch (button.tag) {
case 1000:
[self.subView addSubview:oneView.view];
[currentView removeFromSuperview];
currentView = oneView.view;
break;
case 1001:
[self.subView addSubview:twoView.view];
[currentView removeFromSuperview];
currentView = twoView.view;
break;
case 1002:
[self.subView addSubview:oneView.view];
[currentView removeFromSuperview];
currentView = oneView.view;
break;
case 1003:
[self.subView addSubview:twoView.view];
[currentView removeFromSuperview];
currentView = twoView.view;
break;
default:
break;
}
}
楚楚无敌,转载注明