ios - 如何通过编码管理 .storyboard 或 .xib 文件中的多个 View ?

标签 ios objective-c storyboard

我是 iphone 的新手,我已经在我的 main.storyboard 文件中成功实现了 .xib 文件(图 1),但是无法在同一 .storyboard 文件的下一个 View 中导入相同的 .xib 文件(图 2 中的其他 View )相同的 .storyboard 文件)。请建议我如何在其他 View 上也导入相同的 .xib 文件。 fig-1 main.storyboard file withi imported .xib file

Figure two showing other view of same .storyboard file

ViewController.m(影响main.storyboard)

#import "ViewController.h"
#import "CustomView.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    CustomView *customView = [CustomView customView];
    [self.view addSubview:customView];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

最佳答案

只需转到.storyboard 的下一个 View 页面,单击 身份检查器 -> 类 -> ViewController

它将在您下一次查看相同的 .storyboard 文件时反射(reflect)通用的 xib 文件

关于ios - 如何通过编码管理 .storyboard 或 .xib 文件中的多个 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23903182/

相关文章:

ios - 表格 View 更改时,单元格中的 subview 会丢失颜色

ios - 自动检测AVrecorder没有声音

iOs OAuth 图片发布 + 状态更新问题

ios - 使用 Storyboard 的本地化字符串

ios - 如何将子类 View Controller 的 View 放入父类(super class)基 View Controller 的内容 View 中?

iOS - UIScrollView 中的按钮点击动画

ios - 使用 iphone mapkit 获取点击坐标

javascript - 使用 Objective-C 解析包含未被 ""包围的键的 JSON

iOS - 如何在带有半透明黑色状态栏的 Storyboard中回收前 20 像素

ios - Storyboard中的 Paintcode 样式包