如何在iphone中将数据从一个视图传递到另一个视图 [英] How to pass data from one view to another view in iphone

查看:124
本文介绍了如何在iphone中将数据从一个视图传递到另一个视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将int或字符串数​​据从一个视图传递到另一个视图,请帮助我

I want to pass int or string data from one view to another, please help me

NSUInteger i1 = [array indexOfObject:username];
SSPUserLogedInViewController *logInView = [[SSPUserLogedInViewController alloc] init];
logInView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:logInView animated:YES completion:nil];

我能够下次查看但无法传递数据。
提前致谢。

I am able to next view but not able to pass the data. Thanks in advance.

推荐答案


  1. 为您的传递数据创建一个变量到您的下一个查看。

  2. 使用下一个视图的
    实例,访问您在下一个视图中创建的变量

  3. 将您的值分配给变量

对于您的Ex;


  1. 假设你要传递一个int的值

  1. Suppose you want to pass the value of an int

在下一个视图控制器中:在中复制它* * .h ** file

In Next view controller: copy this in **.h** file




@property( assign)int temp;

@property (assign) int temp;

2。
SSPUserLogedInViewController * logInView =
[[SSPUserLogedInViewController alloc] init];
>

2. SSPUserLogedInViewController *logInView = [[SSPUserLogedInViewController alloc] init]; >

    logInView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;




        logInView.temp = <YOUR_VALUE>
        [self presentViewController:logInView animated:YES completion:nil];





  1. 在下一个视图中:控制器:复制这个在 **。m ** 文件

  1. In Next view controller: copy this in **.m** file




- (void)viewWillAppear

-(void)viewWillAppear

{

   NSLog(@"My Value = %i",_temp);

}

享受编程!!

这篇关于如何在iphone中将数据从一个视图传递到另一个视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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