c_cpp 通用UITabBarController替换
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 通用UITabBarController替换相关的知识,希望对你有一定的参考价值。
//
// Copyright © 2014 Yuri Kotov
//
#import "ADVTabViewController.h"
@interface ADVTabViewController ()
@property (nonatomic, readwrite) UIViewController *selectedViewController;
@end
@implementation ADVTabViewController
- (void)setSelectedIndex:(NSUInteger)index {
if (index != _selectedIndex) {
_selectedIndex = index;
self.selectedViewController = self.viewControllers[index];
}
}
- (void)setViewControllers:(NSArray *)viewControllers {
_selectedIndex = 0;
_viewControllers = [viewControllers copy];
self.selectedViewController = [viewControllers firstObject];
}
- (void)setSelectedViewController:(UIViewController *)controller {
[_selectedViewController willMoveToParentViewController:nil];
[_selectedViewController.view removeFromSuperview];
[_selectedViewController removeFromParentViewController];
_selectedViewController = controller;
[self addChildViewController:controller];
[self addChildView:controller.view];
[controller didMoveToParentViewController:self];
}
- (void)addChildView:(UIView *)subview {
subview.frame = self.view.bounds;
subview.translatesAutoresizingMaskIntoConstraints = YES;
subview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:subview];
}
@end
//
// Copyright © 2014 Yuri Kotov
//
#import <UIKit/UIKit.h>
@interface ADVTabViewController : UIViewController
@property (nonatomic) NSUInteger selectedIndex;
@property (nonatomic, copy) NSArray *viewControllers;
@property (nonatomic, readonly) UIViewController *selectedViewController;
@end
以上是关于c_cpp 通用UITabBarController替换的主要内容,如果未能解决你的问题,请参考以下文章
c_cpp iOS通用全球宏
c_cpp 通用元组模板类
c_cpp C ++中的通用容器可迭代数组类
c_cpp 单片机C编程自定义通用队列接口
c_cpp 多个部分的通用UITableView / UICollectionView数据源
c_cpp 将TSV文件转换为JSON(不是出于通用目的)