<bdo id='aluoA'></bdo><ul id='aluoA'></ul>

      1. <i id='aluoA'><tr id='aluoA'><dt id='aluoA'><q id='aluoA'><span id='aluoA'><b id='aluoA'><form id='aluoA'><ins id='aluoA'></ins><ul id='aluoA'></ul><sub id='aluoA'></sub></form><legend id='aluoA'></legend><bdo id='aluoA'><pre id='aluoA'><center id='aluoA'></center></pre></bdo></b><th id='aluoA'></th></span></q></dt></tr></i><div id='aluoA'><tfoot id='aluoA'></tfoot><dl id='aluoA'><fieldset id='aluoA'></fieldset></dl></div>
        <tfoot id='aluoA'></tfoot>
      2. <small id='aluoA'></small><noframes id='aluoA'>

        <legend id='aluoA'><style id='aluoA'><dir id='aluoA'><q id='aluoA'></q></dir></style></legend>
      3. 如何从 CCScrollView 上的按钮更改标签文本?

        时间:2024-08-12
      4. <legend id='blqtu'><style id='blqtu'><dir id='blqtu'><q id='blqtu'></q></dir></style></legend>
        <i id='blqtu'><tr id='blqtu'><dt id='blqtu'><q id='blqtu'><span id='blqtu'><b id='blqtu'><form id='blqtu'><ins id='blqtu'></ins><ul id='blqtu'></ul><sub id='blqtu'></sub></form><legend id='blqtu'></legend><bdo id='blqtu'><pre id='blqtu'><center id='blqtu'></center></pre></bdo></b><th id='blqtu'></th></span></q></dt></tr></i><div id='blqtu'><tfoot id='blqtu'></tfoot><dl id='blqtu'><fieldset id='blqtu'></fieldset></dl></div>
          <tbody id='blqtu'></tbody>

              <bdo id='blqtu'></bdo><ul id='blqtu'></ul>

              1. <tfoot id='blqtu'></tfoot>

                <small id='blqtu'></small><noframes id='blqtu'>

                  本文介绍了如何从 CCScrollView 上的按钮更改标签文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我之前发布了一些非常相似的内容,但我认为该帖子令人困惑,所以我正在重做.

                  I posted something very similar earlier, but I think the post was confusing so I'm redoing it.

                  这是设置.我正在使用 SpriteBuilder.我有 2 个 CCB 类,MainScene.ccb 和 Scroll.ccb.Scroll.ccb 是一个带有按钮的图层.MainScene 包含一个 CCScrollView 和一个 CCLabelTTF.CCScrollView 正在加载 Scroll.ccb.CCScrollView占据了MainScene界面的一半,另一半是一个CCColor,上面有label.

                  Here's the setup. I am using SpriteBuilder. I have 2 CCB classes, MainScene.ccb and Scroll.ccb. The Scroll.ccb is a layer with a button on it. MainScene contains a CCScrollView and a CCLabelTTF. The CCScrollView is loading Scroll.ccb. The CCScrollView takes up half of the interface of MainScene, and on the other half is a CCColor that has the label on it.

                  当我单击 CCScrollView 上的按钮时,我希望 MainScene 上的标签更改其文本.我遇到的问题是标签文本没有改变.但是,如果我在按钮方法中编写一个 NSLog 以在日志中输出文本,那确实可以工作.

                  When I click the button on the CCScrollView, I want the label on MainScene to change its text. The problem I am having is that the labels text doesn't change. However if I write an NSLog inside the buttons method to output text in the log, that DOES work.

                  我附上了四张图片,以帮助您更好地了解情况.http://imgur.com/a/77XyJ

                  I am including four pictures to help you better understand the situation. http://imgur.com/a/77XyJ

                  在我的主要项目中,我已经坚持了一个多星期.老实说,我已经不知道该做什么了,我尝试了一堆不起作用的东西,而且我的想法已经用完了.

                  I've been stuck on this for over a week now on my main project. I honestly have no clue what to do anymore, I've tried a bunch of things that didn't work, and I've run out of ideas.

                  好的,所以我在调试问题方面得到了一点但更进一步.我在滚动视图中插入了一个标签,并将其命名为 Label2.在按钮方法下,我添加了'Label2.string = @Test"',当我运行程序并单击按钮时,滚动视图上的标签发生了变化.所以看起来当按钮被点击时,它在 MainScene 中查找该方法并找到它,但它无法更新不同 CCNode 上的标签.

                  Okay so I got a little but further in debugging the issue. I inserted a label into the scrollview, and named it Label2. Under the buttons method I added 'Label2.string = @"Test"' and when I ran the program and clicked the button, the label on the scrollview changed. So it seems that when the button is being clicked, it looks in MainScene for the method and finds it, but it can't update a label on a different CCNode.

                  推荐答案

                  你有把这个方法链接到点击我"按钮吗?或者尝试创建一个 IBAction ?

                  Do you have linked this method to the "click me" button ? Or maybe try to create a IBAction ?

                  -(void)testButton {
                  
                         changeLabel.String = @"Changed !";
                  }
                  

                  - (IBAction)testButton:(id)sender {
                  
                      changeLabel.String = @"Changed !";
                  
                  }
                  

                  我的意思是在你的故事板中(使用 ctrl 键创建链接并拖放)

                  i mean in your storyboard ( create the link with ctrl key and drag drop )

                  希望这会对你有所帮助.

                  Hope this will help you.

                  这篇关于如何从 CCScrollView 上的按钮更改标签文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:带有 CCLayer for iOS 6 的 Cocos2d 横向 Gamecenter 身份验证 下一篇:填充抗锯齿聚 cocos2d

                  相关文章

                  • <bdo id='m2yaS'></bdo><ul id='m2yaS'></ul>

                  <i id='m2yaS'><tr id='m2yaS'><dt id='m2yaS'><q id='m2yaS'><span id='m2yaS'><b id='m2yaS'><form id='m2yaS'><ins id='m2yaS'></ins><ul id='m2yaS'></ul><sub id='m2yaS'></sub></form><legend id='m2yaS'></legend><bdo id='m2yaS'><pre id='m2yaS'><center id='m2yaS'></center></pre></bdo></b><th id='m2yaS'></th></span></q></dt></tr></i><div id='m2yaS'><tfoot id='m2yaS'></tfoot><dl id='m2yaS'><fieldset id='m2yaS'></fieldset></dl></div>
                  <tfoot id='m2yaS'></tfoot>

                  <small id='m2yaS'></small><noframes id='m2yaS'>

                  <legend id='m2yaS'><style id='m2yaS'><dir id='m2yaS'><q id='m2yaS'></q></dir></style></legend>