使用导航栏时如何将值从 view2 返回到 view1 [英] How return a value from view2 to view1 when using navigation bar

查看:23
本文介绍了使用导航栏时如何将值从 view2 返回到 view1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 iPhone 开发的新手.使用导航栏时,如何将字符串值从 view2 传送到 view1.我可以通过使用 pushviewcontroller 从 view1 到 view2 再到 view3 来携带字符串值.我需要你的帮助来解决这个问题.

I am New to the iPhone Development. How can i carry a string value from view2 to view1 when using navigation bar. I have no problem in carrying string values from view1 to view2 to view3 to....by using pushviewcontroller But when i come back to previous views using Back button of navigation bar, I cannot able to hold string values. I need your help in solving this issue.

提前致谢

推荐答案

如果将当前类的引用传递给下一个类并使用该引用更改值,则可以轻松完成此操作.

This thing can be done easily if the pass the reference of the current class to the next class and change the values by using this reference.

喜欢:要推送的类.

@interface B:UIViewController{
   id delegate;
}
@property (nonatomic,retain) id delegate;
@end

@implementation B
@synthesize delegate;

-(void)methodA{
  [delegate setNewString2:@"Madhup"];
}

@end

您从中推送 B 的类:

The class from which you are pushing B:

@interface A:UIViewController{
   NSString *newString;
}
@property (nonatomic,retain)  NSString *newString;
@end


 @implementation A
 @synthesize newString
- (void)method2{
     B *newBObject = .......;
     [newBObject setDelegate:self];
     [self.navigationController pushViewCo.......];
  }
 @end

希望这会有所帮助.

这篇关于使用导航栏时如何将值从 view2 返回到 view1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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