请查看下面的图片,帮我找到这个类的文件所有者。
通常我会将我的UILabel连接到它,但是,可惜,我找不到它。
问题:我应该将标签连接到什么?
故事板:
同时,类设置如下:
![enter image description here](https://istack.dev59.com/5V2Lt.webp)
通常我会将我的UILabel连接到它,但是,可惜,我找不到它。
问题:我应该将标签连接到什么?
故事板:
![enter image description here](https://istack.dev59.com/NvNxY.webp)
![enter image description here](https://istack.dev59.com/5V2Lt.webp)
由于storyboards没有所有者,您可以使用视图控制器(View Controller)代替。
通过Ctrl点击(或右键单击)标签,并将蓝色线连接到橙色的视图控制器(View Controller)上。
UINavigationController* nav =
(UINavigationController*)[[UIStoryboard storyboardWithName:@"Storyboard"
bundle:nil]
instantiateInitialViewController];
// there is no file's owner...
// so we can't just draw the connection from button items to ourself,
// because we are not proxied in the storyboard
// so, locate the button items in some other way and do it in code
UIViewController* root = [nav.viewControllers objectAtIndex: 0];
[root.navigationItem.leftBarButtonItem setTarget:self];
[root.navigationItem.leftBarButtonItem setAction:@selector(save:)];
[root.navigationItem.rightBarButtonItem setTarget:self];
[root.navigationItem.rightBarButtonItem setAction:@selector(cancel:)];
[self becomeFirstResponder];
UINavigationController* nav =
(UINavigationController*)[[UIStoryboard storyboardWithName:@"Storyboard"
bundle:nil]
instantiateInitialViewController];
菜单:导航 - 在项目导航器中显示 在项目导航器中,点击“主故事板” 菜单:视图 - 显示辅助编辑器 你应该在左侧看到故事板和标签,右侧是视图控制器.h文本。 点击标签,按住控制键,将蓝色线条拖到右侧的View Controler.h源代码上。输入一个引用名称(例如myLabel),然后点击连接。
自动地,你会看到类似于这样的生成: @property (weak,nonatomic) IBOutlet UILabel *myLabel;
在View Controler.m中,你会看到类似于这样的生成: @synthesize *myLabel;
在你的IBAction事件中,你可以设置标签: myLabel.text =