我有一个名为 FirstUIViewController 和 SecondUIViewController 的两个 UIViewController,当我按下 FirstUIviewController 中的按钮时,我想从 FirstUIViewController 更改 SecondtUIViewController 上的 UILabel 的文本。我不知道该怎么做我是objective-c和ios开发的新手。
这是我目前拥有的
FirstUIViewController.h
#import <UIKit/UIKit.h>
@interface FirstUIViewController
IBAction Button1:(id)sender;
@end
第一UIViewController.m
#import "MainViewController.h"
@implementation FirstUIViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewdidload {
//some codes here.
}
第二个UIViewController.h
#import <UIKit/UIKit.h>
@interface SecondUIViewController {
IBOutlet UILabel *label;
}
@end
第二个UIViewController.m
#import "SecondUIViewController.h"
@implementation FirstUIViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewdidload {
//some codes here.
}