在Tag Bar中使用Navgation

[size=x-large]前面分别学到了Tag Bar和Navigation的使用,这次我们把他合起来使用,效果如下图[/size]
[img]http://dl.iteye.com/upload/attachment/351231/1d241694-9eac-36a7-9104-c70d08c61c89.png[/img]

[img]http://dl.iteye.com/upload/attachment/351233/b54e23a7-7704-3110-83e4-c5afcde3f5d1.png[/img]

[img]http://dl.iteye.com/upload/attachment/351235/24a201d2-593a-3bec-985c-cc9777e4ff99.png[/img]
[size=x-large]首先创建项目,选择window based application。项目名称为Nav_Tagbar。在.h中完成代码[/size]
#import <UIKit/UIKit.h>
@interface Nav_TagbarAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
UITabBarController *rootController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *rootController;
@end

[size=x-large]在.m中完成代码[/size]

#import "Nav_TagbarAppDelegate.h"
@implementation Nav_TagbarAppDelegate
@synthesize window;
@synthesize rootController;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[window addSubview:rootController.view];
[window makeKeyAndVisible];
return YES;
}
- (void)dealloc {
[rootController release];
[window release];
[super dealloc];
}
@end

[size=x-large]再创建三个类,名为navView,secondView,thirdView,并生成视图。下面进行页面设计。双击MainWindow.xib,首先将一个Tag Bar Controller拖入nib主窗口中,按住Ctrl将Nav Tagbar App Delegate拖入Tag Bar Controller。之后将一个Navigation Controller拖入Tag Bar Controller中,如图[/size]
[img]http://dl.iteye.com/upload/attachment/351255/e4f76c7b-6da4-3c09-bdfc-e5215159df92.png[/img]
[size=x-large]再做好相对界面的视图和控制器选择。这是nav的选择[/size]
[img]http://dl.iteye.com/upload/attachment/351263/1f58f99c-5b29-3436-bbdb-7526f4e32641.png[/img]

[img]http://dl.iteye.com/upload/attachment/351265/80f5bb13-3f96-3e8b-9368-ce5a54a0148f.png[/img]

[size=x-large]在navView.xib中生成一个按钮,实现入栈跳转。在相应的.h.m文件中实现如下代码[/size]
#import <UIKit/UIKit.h>
@interface navView : UIViewController {
}
-(IBAction)buttonPressed;
@end

#import "navView.h"
#import "thirdView.h"
@implementation navView
-(IBAction)buttonPressed{
thirdView *mythirdView = [[thirdView alloc] initWithNibName:@"thirdView" bundle:nil];
[self.navigationController pushViewController:mythirdView animated:YES];
[mythirdView release];
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值