将笔尖视图加载到另一个笔尖视图中

发布于 2024-12-22 22:26:13 字数 1584 浏览 2 评论 0原文

我有两个 UIViews,让我将它们称为 ABAB 的容器,每一个都是使用 Interface Builder 创建的。

我需要使用界面生成器将我的 B 视图添加到 A 中,如下图所示:

使用界面生成器创建的 UIView

问题是视图已加载但它是空的,当我调试它时,我看到每个组件都已创建。

B UIView 类定义为:

Bh (ISMSliderCustomizing.h)

@interface ISMSliderCustomizable : UIView {

    IBOutlet UIView *view;
    IBOutlet UISlider *slider;
    IBOutlet UILabel *minLabel;
    IBOutlet UILabel *maxLabel;
    IBOutlet UIImageView *tooltip;
    IBOutlet UILabel *sliderValue;
}

@property (nonatomic, retain) IBOutlet UIView *view;
@property (nonatomic) float min;
@property (nonatomic) float max;
@property (nonatomic) float initialValue;

@end

Bm (ISMSliderCustomizing.m)

- (id)initWithFrame:(CGRect)frame 
{
    self = [super initWithFrame:frame];
    if (self) 
    {
        [[NSBundle mainBundle] loadNibNamed:@"ISMSliderCustomizable" owner:self options:nil];
        [self addSubview:self.view];
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];

    [[NSBundle mainBundle] loadNibNamed:@"ISMSliderCustomizable" owner:self options:nil];
    [self addSubview:self.view];
}

我需要将 UIView 添加到另一个 UIView,每个UIView都是用IB创建的。

I have two UIViews, let me called them as A and B. A is the container of B and each one is created using Interface Builder.

I need to add my B view into A using interface builder, like this image:

A UIView created using interface builder

B UIView created using interface builder

The problem is that the view is loaded but it's empty, when I debugged it I saw that every component is created.

The B UIView class definition is:

B.h (ISMSliderCustomizable.h)

@interface ISMSliderCustomizable : UIView {

    IBOutlet UIView *view;
    IBOutlet UISlider *slider;
    IBOutlet UILabel *minLabel;
    IBOutlet UILabel *maxLabel;
    IBOutlet UIImageView *tooltip;
    IBOutlet UILabel *sliderValue;
}

@property (nonatomic, retain) IBOutlet UIView *view;
@property (nonatomic) float min;
@property (nonatomic) float max;
@property (nonatomic) float initialValue;

@end

B.m (ISMSliderCustomizable.m)

- (id)initWithFrame:(CGRect)frame 
{
    self = [super initWithFrame:frame];
    if (self) 
    {
        [[NSBundle mainBundle] loadNibNamed:@"ISMSliderCustomizable" owner:self options:nil];
        [self addSubview:self.view];
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];

    [[NSBundle mainBundle] loadNibNamed:@"ISMSliderCustomizable" owner:self options:nil];
    [self addSubview:self.view];
}

I need to add a UIView into another UIView which every UIView is created with IB.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的心境我的脸 2024-12-29 22:26:14

我认为问题是 b.xib 中的 UIView 是 320x480
但 a.xib 中的视图 B 不是
所以它不是空的,只是超出了范围

I think the problem is UIView in b.xib is 320x480
but View B in a.xib is not
so it's not empty,it just out of range

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文