gpt4 book ai didi

ios - 从 UIController 调用 UIView

转载 作者:行者123 更新时间:2023-11-29 01:55:52 26 4
gpt4 key购买 nike

我正在尝试从我的 ViewController 调用 UIView FirstScreen。

但是我不知道该怎么做。

View Controller :

#import "ViewController.h"
#import "FirstScreen.h"

@interface ViewController ()
{
FirstScreen *f;
}

FirstScreen.m:

#import "FirstScreen.h"       
@implementation FirstScreen

- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self didLoad];
}
return self;
}

-(void) didLoad{
[self addLabel];
[self addImageView];
}

最佳答案

@implementation FirstScreen

 - (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self didLoad];
}
return self;
}

-(void) didLoad
{
f = [[FirstScreen alloc] initWithFrame:CGRectMake(0, 0, self.view.size.width, self.view.size.height)];
[self.view addSubview:f];
}

关于ios - 从 UIController 调用 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30863933/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com