ViewController页面传到TwoViewController页面name的值:两个页面都拥有一个字符串对象,跳转之前,把对象传过去。
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (nonatomic,copy)NSString *name;
@end
- (void)viewDidLoad {
[super viewDidLoad];
self.name = @"ranki";
TwoViewController *two = [[TwoViewController alloc]init];
two.name = self.name;
// [self.navigationController pushViewController:two animated:YES];
[self presentModalViewController:two animated:YES];
}
@interface TwoViewController : UIViewController
@property (nonatomic,copy)NSString *name;
@end
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
NSLog(@"~~~~~~~~~~~~~~~~~~~~~~~%@",self.name);
}
时间: 2024-10-12 12:42:10