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

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

        以编程方式添加按钮以执行 segue

        时间:2023-07-06
        <i id='pLlte'><tr id='pLlte'><dt id='pLlte'><q id='pLlte'><span id='pLlte'><b id='pLlte'><form id='pLlte'><ins id='pLlte'></ins><ul id='pLlte'></ul><sub id='pLlte'></sub></form><legend id='pLlte'></legend><bdo id='pLlte'><pre id='pLlte'><center id='pLlte'></center></pre></bdo></b><th id='pLlte'></th></span></q></dt></tr></i><div id='pLlte'><tfoot id='pLlte'></tfoot><dl id='pLlte'><fieldset id='pLlte'></fieldset></dl></div>
          <bdo id='pLlte'></bdo><ul id='pLlte'></ul>
          <tfoot id='pLlte'></tfoot>

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

          • <legend id='pLlte'><style id='pLlte'><dir id='pLlte'><q id='pLlte'></q></dir></style></legend>
              <tbody id='pLlte'></tbody>

                  本文介绍了以编程方式添加按钮以执行 segue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用代码即时"创建一个按钮,并且我希望该按钮能够执行转到不同的控制器.据我所知,以编程方式创建 segue 是不可能的,但是如果创建的按钮不在我的故事板上,我怎么能通过呢?

                  I am trying to create a button 'on the fly' using code, and i want that button to perform segue to a different controller. As far as i know, creating segue programmatically is not possible, but how can i get pass that if the created button is not on my storyboard?

                  这是创建按钮的代码:

                  - (void)addButton:(UIView*)view inLocation:(CGPoint)point
                  {
                  
                      UIButton *but=[UIButton buttonWithType:UIButtonTypeRoundedRect];
                      but.frame= CGRectMake(point.x, point.y,30,30);
                      [but setTitle:@"CHOOSE" forState:UIControlStateNormal];
                      // The nilSymbol should call a method that will perform the segue
                      [but addTarget:self action:@selector(nilSymbol) forControlEvents:UIControlEventTouchUpInside];
                      [view addSubview:but];  
                  }
                  

                  有什么选择吗?

                  推荐答案

                  在 Interface Builder 中,创建一个 segue.由于您无法将 segue 连接到按钮(它还不存在),只需将 segue 连接到起始 ViewController.然后,当您创建按钮时:

                  In Interface Builder, create a segue. Since you can't connect the segue to the button (it doesn't exist yet), simply connect the segue to the starting ViewController. Then, when you create the button:

                  // ....
                  [but addTarget:self action:@selector(someMethod) forControlEvents:UIControlEventTouchUpInside];
                  // ....
                  

                  而在一些方法中:

                  -(void)someMethod
                  {
                      [self performSegueWithIdentifier:@"segueIdentifier" sender:self];
                  }
                  

                  这篇关于以编程方式添加按钮以执行 segue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:用于按钮触摸事件的自定义 UIButton 类 下一篇:Xcode iOS 按下按钮然后向上拖动第二个按钮

                  相关文章

                • <tfoot id='FXL5i'></tfoot>
                • <small id='FXL5i'></small><noframes id='FXL5i'>

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

                    • <bdo id='FXL5i'></bdo><ul id='FXL5i'></ul>
                    <legend id='FXL5i'><style id='FXL5i'><dir id='FXL5i'><q id='FXL5i'></q></dir></style></legend>