用于打开新视图的按钮 [英] Button To Open New View

查看:50
本文介绍了用于打开新视图的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近成为会员,因为我注意到这里有很多知识,而且我是制作 iOS 应用程序的完全初学者.我目前正在制作一个完美适用于我想要它做的所有事情的应用程序.唯一的问题是我向应用程序添加了一个新按钮,但我不知道如何用它打开一个新视图或如何将它连接到 segue 或任何会打开新视图的东西.我以编程方式制作了按钮,作为选择器,我有一个名为 pushnext 的方法.我正在尝试实现一种将打开视图的方法,但我所知道的是我想要显示的视图中的信息包含在 GridViewController.m 中,我不知道如何调用该视图,并且我已经阅读了许多其他帖子在这里,但我似乎无法弄清楚.我希望你们能帮助我.感谢您抽出宝贵时间.

I recently became a member as I noticed that there is alot of knowledge here and I am a complete beginner at making iOS apps. I am currently making an app that works perfectly for everything I want it to do. The only problem is that I added a new button to the app and I do not know how to open a new view with it or how to hook it up to a segue or whatever will open the new view. I made the button programmatically, and as a selector I have a method called pushnext. I am trying to implement a method that will open a view but all I know is that the information in the view I want to display is contained in GridViewController.m , I do not know how to call that view and I have read many other posts here but I just can't seem to figure it out. I hope you guys can help me out. Thank you for your time.

我还使用了以下内容的故事板:

I am also using a storyboard with the following:

标签栏控制器(2 个图标):然后从那里拆分为第一个视图控制器,然后拆分为导航控制器.它从导航控制器连接到网格视图控制器(我希望按钮打开什么),然后从网格视图控制器连接到详细信息视图连接.如果可以,请帮助我.如果对您有帮助,我遵循了此处的指南 http://mobile.tutsplus.com/tutorials/iphone/design-build-a-small-business-app-custom-detail-views/

Tab Bar Controller (2 icons) : then from there it splits to First View Controller and then to Navigation Controller. From Navigation Controller it is connected to Grid View Controller (What I want the button to open) and then from Grid View Controller it has a connection to Detail View Connection. Please help me if you could. I followed the guides found here if it helps you http://mobile.tutsplus.com/tutorials/iphone/design-build-a-small-business-app-custom-detail-views/

我添加了下面的代码,这样对你们来说更容易.

I have added the code I have below so it is easier for you guys.

现在终于看到了,原因是我用的是添加评论"而不是回答问题.

I finally see it now, the reason was because I was using the "add comment" instead of answer question.

这是我在 FirstViewController.h 中的内容

This is what I Have in FirstViewController.h

-(void)pushnext;

然后我在 FirstViewController.m 中有我的按钮

Then I have my button in FirstViewController.m

self.roundButton = [self createButtonWithPicture:CGRectMake(110, 200, 100, 100) andLabel:@""];
[self.view addSubview:roundButton];

[self.roundButton addTarget:self action:@selector(pushnext:) forControlEvents:UIControlEventTouchUpInside];

也在 FirstViewController.m 里面,我有我想用我的按钮打开新视图的实现:

Also Inside of FirstViewController.m I have the implementation I want to use for opening the new view with my button:

-(void)pushnext{
[UIView transitionFromView:contact toView:cable duration:1.0 options UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished){
    [contact release];
   }];

从那里我希望方法 pushnext 为我打开该视图,但我似乎无法理解.我在应用程序加载后弹出的第一个屏幕中设置了按钮,但我不知道该视图叫什么,所以我在我的代码中称它为 contact,我希望它打开包含所有内容的视图GridViewController.m 包含的信息我只是不知道该怎么做.您建议使用 segue 来连接它们,但我应该如何将 segue 连接到我的按钮.我还有一个问题,我的按钮不是通过 IB 以编程方式完成的.谢谢你的时间,我希望你能帮助我.再次感谢您,我只是绝望了,因为我已经被困了好几天试图通过阅读和示例来弄清楚它,但我就是不明白.我还附上了我的故事板的图片.在那里您可能会更清楚地看到我在说什么,我在标签栏控制器"页面中对我的按钮进行了编程,但我希望该按钮打开标有网格视图控制器-秒"的页面,图像在这里 http://i.stack.imgur.com/YKs1o.png

From there I want the method pushnext to open that view for me but I just can't seem to get it. I have my button setup in the very first screen that pops up after the app loads, and I don't know what that view is called so I called it contact in my code, and I want it to open the view that has all the information contained with GridViewController.m I just don't know what to do. You suggested to use a segue to connect them but how am I supposed to connect a segue to my button. I also have the problem that my button is done programmatically not through IB. Thank you for your time and I hope you can help me. Thank you once again, I am just desperate because I have been stuck for days trying to figure it out by reading and examples and I just don't get it. I also attached a picture of my storyboard. There you might be able to see better what I am talking about, I have my button programmed in the "Tab Bar Controller" page but I want the button to open the page labeled "Grid View Controller-Second" and the image is here http://i.stack.imgur.com/YKs1o.png

推荐答案

您可以通过按住 Ctrl 并从 VIEW CONTROLLER 图标拖动到下一个视图的方式在故事板中创建转场.单击 segue 并在属性检查器中为其命名.

You can create a segue in storyboard by Ctrl+dragging from the VIEW CONTROLLER icon to your next view. Click the segue and give it a name in the attribute inspector.

现在在按下按钮的代码中,只需调用:[self performSegueWithIdentifier:@"segueName"] 它将执行转场到下一个视图.

Now in your button pressed code, simply call: [self performSegueWithIdentifier:@"segueName"] and it'll perform the segue to the next view.

从属性检查器中选择您的动画类型.

Choose your animation type from the attribute inspector.

这篇关于用于打开新视图的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆