0
点赞
收藏
分享

微信扫一扫

[IOS]通过子view控制tab的页面转换


-(void)setSelectButton:(UIButton*)sender{

if(sender == _btPayQR && ![_btPayQR isSelected]){

[_btPayScan setBackgroundColor:[UIColor whiteColor]];
[_bgView setBackgroundColor:[UIColor whiteColor]];
[_btPayScan setSelected:false];
[_btTranSporttation setSelected:false];

[sender setBackgroundColor:[[UIColor alloc] initWithRed:115/255.0 green:115/255.0 blue:115/255.0 alpha:1]];
[sender setSelected:YES];

[self addChildViewWithStoryboardName:@"PToM" identifier:@"PGPToMQRCodeViewController"];
}else if(sender == _btPayScan && ![_btPayScan isSelected]){
[_btPayQR setBackgroundColor:[UIColor whiteColor]];
[_bgView setBackgroundColor:[UIColor whiteColor]];
[_btPayQR setSelected:false];
[_btTranSporttation setSelected:false];

[sender setBackgroundColor:[[UIColor alloc] initWithRed:115/255.0 green:115/255.0 blue:115/255.0 alpha:1]];
[sender setSelected:YES];

[self addChildViewWithStoryboardName:@"PToM" identifier:@"PGPToMScanViewController"];

 在当前页面做tab的翻页

不同的按钮点击就显示不同的内容

 

- (void)addChildViewWithStoryboardName:(NSString *)storyboardName identifier:(NSString *)identifier {

if ([self.subView.subviews count] != 0) {
[self.subView.subviews[0] removeFromSuperview];
}

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
PGBaseViewController *controller = [storyboard instantiateViewControllerWithIdentifier:identifier];
[self addChildViewController:controller];
[controller.view setBackgroundColor:[UIColor clearColor]];
[controller.view setFrame:self.subView.bounds];
[self.subView addSubview:controller.view];
}

 清空subview数组并加载子页面

举报

相关推荐

0 条评论