如何在不同的UIViewcontroller之间切换

发布于 2024-11-28 20:50:03 字数 997 浏览 2 评论 0原文

我想编写一个自定义开关,将位于两个自定义 tabBar 上。其结构如下 - 在此处输入图像描述

我想使用 uiviewcontroller。

现在我使用以下代码:

- (void)changeViewController:(NSInteger)sender{

    if(viewController){
        [viewController.view removeFromSuperview];
        [viewController release];  
        NSLog(@"released");
    }

    switch (sender) {
        case 1:      
            viewController = [[VC1 alloc] init];
            break;
        case 2:
            viewController = [[VC2 alloc] init];
            break;
        case 3:
            viewController = [[VC3 alloc] init];
            break;

        default:
            break;
    }

    [viewController.view setFrame:CGRectMake(0, 100, 320, 380)];
    [self.view addSubview:viewController.view];

}

但我认为这是错误的!

可以在这样的结构中使用 - presentModalViewControllerdismissModalViewControllerAnimated 或其他方法来处理相似性 navigationViewController 吗?

I want to write a custom switch that will be located two custom tabBar. Its structure is as follows - enter image description here

I want to use uiviewcontroller.

Now I use the following code:

- (void)changeViewController:(NSInteger)sender{

    if(viewController){
        [viewController.view removeFromSuperview];
        [viewController release];  
        NSLog(@"released");
    }

    switch (sender) {
        case 1:      
            viewController = [[VC1 alloc] init];
            break;
        case 2:
            viewController = [[VC2 alloc] init];
            break;
        case 3:
            viewController = [[VC3 alloc] init];
            break;

        default:
            break;
    }

    [viewController.view setFrame:CGRectMake(0, 100, 320, 380)];
    [self.view addSubview:viewController.view];

}

but I think it's wrong!

Can be used in such a structure - presentModalViewController, dismissModalViewControllerAnimated or other method to work on the similarity navigationViewController?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

×眷恋的温暖 2024-12-05 20:50:03

试试这个

[self.navigationController pushViewController:viewController animated:YES];

[self.view addsubview:viewcontroller.view];

Try this

[self.navigationController pushViewController:viewController animated:YES];

or

[self.view addsubview:viewcontroller.view];
鹿! 2024-12-05 20:50:03

你可以尝试这个 - [self.navigationController PushViewController:viewControllerAnimated:NO];

[self.navigationController popToViewController:targetControlleranimated:YES];

我真的会订阅navigationController 的内存管理和远响应和无缝行为...

希望这会有所帮助。

You could try this - [self.navigationController pushViewController:viewController animated:NO];

or [self.navigationController popToViewController:targetController animated:YES];

I would really subscribe navigationController for its memory management and a far responsive and seamless behaviour...

hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文