iPhone:如何从另一个控制器类访问View控制器类中的数据?

编程入门 行业动态 更新时间:2024-10-27 06:28:47
本文介绍了iPhone:如何从另一个控制器类访问View控制器类中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的应用程序中,我有一个Entry表单,其中有六个Text字段

In my application I have one Entry form in which there are six Text fields

  • 名称:UITextField
  • 出生日期:UITExtField
  • 年龄:UITextField
  • 地址:UITextField
  • 电话号码:UITextField
  • 图片:UIIMageView
  • 现在我想要的是我希望所有这些字段的值都在其他ViewController类的相同字段中.怎么可能.

    Now What I want is that I want all these fields value in the same fields of other ViewController class. How it could be possible .

    请帮助我,我真的需要帮助.

    Please help me I really need help for this..

    特别鸣谢

    推荐答案

    您可以通过在委托类中实现getter和setter来实现.

    You can achieve that by implementing getter and setters in the delegate class.

    在代理.h文件中

    包括UIApplication委托

    Include UIApplication delegate

    @interface DevAppDelegate : NSObject <UIApplicationDelegate> NSString * currentTitle; - (void) setCurrentTitle:(NSString *) currentTitle; - (NSString *) getCurrentTitle;

    在Delegate实现类.m

    In Delegate implementation class .m

    -(void) setCurrentLink:(NSString *) storydata{ currentLink = storydata; } -(NSString *) getCurrentLink{ if ( currentLink == nil ) { currentLink = @"Display StoryLink"; } return currentLink; }

    因此,要评估的变量是通过setters方法和要在其中放置字符串的类在currentlink字符串中设置的,只需使用getter方法即可.

    So the variable you to assess is set in the currentlink string by setters method and class where you want the string ,just use the getter method.

    更多推荐

    iPhone:如何从另一个控制器类访问View控制器类中的数据?

    本文发布于:2023-11-17 04:23:30,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1608814.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:控制器   类中   数据   iPhone   View

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!