跨多个视图控制器的功能 [英] Function across multiple view controllers

查看:22
本文介绍了跨多个视图控制器的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个功能,以便我请求经理覆盖",它会显示一个屏幕,供经理输入密码并按下批准按钮.我该怎么做?它必须在多个功能中吗?有没有一种方法可以调用一个函数并返回信息?完成工作可以满足我的需要吗?我不知道从哪里开始.

I am trying to make a function so that I request a 'manager override' where it presents a screen for a manager to enter their password and press an approve button. How should I do this? Will it have to be in multiple functions? Is there a way that I can call one function and it present the information back? Would a completion work for what I need? I have no ideas where to start for this.

我的设置如下:

一个视图控制器请求经理批准,然后一个带有文本框和批准按钮的屏幕向上滑动.我希望批准按钮触发身份验证和关闭屏幕

A view controller asks for manager approval, then a screen slides up with text boxes and an approve button. I want the approve button to trigger authenticating and dismissing the screen

推荐答案

假设您不想要 Framework 目标(这听起来对您想要的东西来说太过分了)只需将该函数标记为public"并将其移出任何班级.我刚刚在一个示例项目中尝试过,它有效.

Assuming you don't want a Framework target (that sounds like overkill for what you want) simply mark the function as "public" and move it outside of any class. I just tried in a sample project and it works.

它看起来很重要 - 请记住将它保存在项目中已有的文件中.(我的示例项目不适用于菜单选项 File|Add|New|File.)

It looks important - remember to keep it in a file already in the project. (My sample project didn't work with menu option File|Add|New|File.)

现在,如果您真的想要可移植性,请查看如何创建框架项目.

Now, if you really want portability, check out how to create a Framework project.

这篇关于跨多个视图控制器的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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