在没有 UINavigationControler 的情况下如何导航到另一个控制器?

发布于 2024-10-19 22:53:31 字数 769 浏览 0 评论 0原文

我在 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 他们的,我该怎么做?

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

I have following coding in my ViewDidLoad of ViewController

- (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 !"); }

Now I want to tap and switch to another controller and I want UITabBarController their, how can I do that?

If anyone is not clear, may ask again to me

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

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

发布评论

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

评论(2

桃酥萝莉 2024-10-26 22:53:31

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

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

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

You can call the new controller as modelviewController..That is one option..and in the viewDidLoad of the newController init tabController there..

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

.Or If you want push navigation from right to left..You can animate the view of the new Controller from right to left and push the view of current controller outside to the left of the screen..another option..but I recommend first one...

左耳近心 2024-10-26 22:53:31

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

Take a button on tapping which you should be navigated to another controller. Write a method for the button and in the view did load method of the new controller, initiate the tabbarcontroller

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