应用一个类轻松实现UITabBar and UINavigationController的界面跳转
来源:互联网 发布:手机淘宝流量钱包 编辑:程序博客网 时间:2024/06/06 20:35
相信大家在iOS界面开发中经常会用到UITabBar and UINavigationController
今天就给大家写个简单的方法实现这个功能
这里我会用到一个类和一个plist文件
首先我们可以先创建5个界面出来
这是我创建的5个界面
然后我们再创建一个plist文件
具体方法
这样就可以创建一个plist文件,然后我们在里面写入以下内容
接下来我们再创建一个叫做ConfigCenter的类
然后再ConfigCenter.h中定义一些属性和方法
@interface JConfigCenter :NSObject
@property (nonatomic,retain)NSMutableDictionary *config;
@property (nonatomic,copy)NSString *path;
+(id)getConfigWithKey:(NSString *)key;
+(id)getRootViewControllers;
@end
接下来我们再在ConfigCenter.m中实现
#import "JConfigCenter.h"
@implementation JConfigCenter
+(id)getRootViewControllers
{
return [selfgetConfigWithKey:kROOT_VIEW_CONTROLLERS];
}
+(id)getConfigWithKey:(NSString *)key
{
return [[selfgetConfig]objectForKey:key];
}
+(id)getConfig
{
staticNSDictionary *config;
if (!config) {
NSString * path = [[NSBundlemainBundle]pathForResource:@"config"ofType:@"plist"];
config = [NSDictionarydictionaryWithContentsOfFile:path];
}
return config;
}
@end
#import "JAppDelegate.h"
#import "JConfigCenter.h"
@implementation JAppDelegate
- (void)dealloc
{
[_windowrelease];
[superdealloc];
}
-(void)buildLayout
{
UITabBarController *tbc = [[UITabBarControlleralloc]init];
NSArray *controllers = [JConfigCentergetRootViewControllers];
for (NSString *controllerin controllers) {
UIViewController *vc = [[NSClassFromString(controller)alloc]init];
UINavigationController *nav = [[UINavigationControlleralloc]initWithRootViewController:vc];
[tbc addChildViewController:nav];
}
self.window.rootViewController = tbc;
}
#pragma mark -
#pragma mark JAppDelegate lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindowalloc]initWithFrame:[[UIScreenmainScreen]bounds]]autorelease];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColorwhiteColor];
[selfbuildLayout];
[self.windowmakeKeyAndVisible];
return YES;
}
@end
效果就如图:
希望这个方法可以帮到大家!
接下来还会继续实现各个界面的真正功能,希望大家能够支持!
- 应用一个类轻松实现UITabBar and UINavigationController的界面跳转
- 解决UINavigationController+UITabbar跳转页面隐藏tabbar的一种方法
- Java轻松实现跳转界面
- UINavigationController 界面跳转
- UINavigationController 界面跳转情况
- 在Java中轻松实现界面跳转
- (三)UITabBar and UINavigationController基础教程之UITableView的插入删除移动
- Android中多界面跳转的一个简单应用
- 实现界面的跳转
- (一)UITabBar and UINavigationController基础教程之切换页面
- Android 界面跳转问题:开发实现连续跳转几个界面后在最后一个界面完美跳回最初的界面
- Android实现跳转到外部应用的某个Activity界面
- JavaFX之实现桌面应用的界面跳转
- 创建一个简单的javaweb工程实现界面跳转
- 轻松实现类VC界面
- 轻松实现类VC界面
- 轻松实现类VC界面
- 轻松实现类VC界面
- oracle 预定义例外
- 1-10 实验8 网络通信实验2 组播通信
- Windows下Code::Blocks+wxWidgets开发配置总结
- Android Gallery3D源码分析
- Web面试题2
- 应用一个类轻松实现UITabBar and UINavigationController的界面跳转
- oracle 自定义例外
- Web面试题3
- Qt学习笔记(十一)网络
- oracle 视图
- Android常用控件之HorizontalScrollView代替Gallery
- ViewPager+Fragment基本使用方法(附源码)
- Lua手册
- 程序员必知的8大排序(三)-------冒泡排序,快速排序(java实现) .