search

Home  >  Q&A  >  body text

ios - 如何打开一个控制器 ,但是在页面上完全不显示出来 ?

如题如何打开一个控制器 ,但是在页面上完全不显示出来 ?

我想调用控制器里面的借口和方法实现一些功能,但是如果打开那个控制器体验就很不好,如果再实现一遍那些借口和方法又显得太冗余,请问如何实现?

PHPzPHPz2888 days ago427

reply all(5)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 17:42:28

    Depending on your needs, what you want to implement is a tool class, rather than opening a ViewController and not displaying it. The latter is obviously a more Ugly solution and usually introduces more baffling problems.

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 17:42:28

    If the interfaces and methods in a controller need to be used in other places, and they are used when it is not displayed, then these interfaces and methods should be extracted separately and placed in another place, like this For the original controller and other places that need to be used, just import the class (or just the function) that you extracted separately. Opening a controller without displaying it, just to call some of its methods, is likely to be problematic.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:42:28

    Why does it have to be implemented in the controller? Why not just create a class?

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 17:42:28

    I know two ways to display the view of a controller. The first is to set the controller as the root view controller rootViewController; the second is to set the controller as the childViewController of the root view controller and put The view of the controller is added to the View of the root view controller. As long as you do not perform the above operations and just create the controller object and call its method, the view controller will not be displayed.

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 17:42:28

    It is more reliable to build a tool class. If there is anything that needs the help of the controller, it can be implemented as a proxy. You introduce a controller for no reason and hide it. Have you ever thought about the feelings of the compiler and the controller? -

    reply
    0
  • Cancelreply