【问题标题】:how can I navigate to another controller without UINavigationControler?如何在没有 UINavigationController 的情况下导航到另一个控制器?
【发布时间】:2011-03-03 06:47:06
【问题描述】:

我在 ViewController 的 ViewDidLoad 中有以下编码

- (void)viewDidLoad {
[super viewDidLoad];
UIImageView* view = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @"logo.png"]];
view.frame = CGRectMake(300, 200, 200, 350);
[self.view addSubview:view];


UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(300, 800, 200, 50)];
label.textColor = [UIColor blackColor];
[label setBackgroundColor:[UIColor clearColor]];
[label setFont:[UIFont systemFontOfSize:30]];
[label setText: @"Tap to Enter"];

[self.view addSubview:label];
[label release]; }

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"Hello, You Tapped !"); }

现在我想点击并切换到另一个控制器,我想要他们的 UITabBarController,我该怎么做?

如果有人不清楚,可以再问我

【问题讨论】:

    标签: ios cocoa-touch uinavigationcontroller


    【解决方案1】:

    您可以将新控制器称为modelviewController..这是一个选项..在newController init tabController的viewDidLoad中..

    UIViewController *newViewController = [[UIViewController alloc] init];
    [self presentModalViewController:newViewController animated:YES];
    

    .或者如果你想从右到左推送导航..你可以动画新控制器的视图从右到左并将当前控制器的视图推到屏幕左侧..另一个选项..但是我推荐第一个...

    【讨论】:

      【解决方案2】:

      点击一个按钮,您应该导航到另一个控制器。为按钮编写一个方法,并在视图中加载新控制器的方法,启动tabbarcontroller

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-08-09
        • 1970-01-01
        • 2021-06-09
        • 1970-01-01
        • 1970-01-01
        • 2013-08-28
        • 1970-01-01
        相关资源
        最近更新 更多