gpt4 book ai didi

ios - 如何在ios的mainView Controller 中加载xib文件

转载 作者:行者123 更新时间:2023-11-29 01:14:02 25 4
gpt4 key购买 nike

我对 iOS 非常陌生,在我的应用程序中,我正在我的 mainView Controller 中加载 UIView xib 文件,在此 xib 文件中,我插入了一个 UITextField 但是当我在该文本中插入了不适用的文本,请帮助我。

主视图 Controller :-

#import "ViewController.h"

@interface ViewController ()
{
FirstView * test1;
}

@end

@implementation ViewController
@synthesize rightView;

- (void)viewDidLoad {
[super viewDidLoad];

test1 = [[[NSBundle mainBundle] loadNibNamed:@"FirstView" owner:self options:nil] objectAtIndex:0];
test1.frame = CGRectMake(0, 0, rightView.frame.size.width, rightView.frame.size.height);

test1.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[rightView addSubview:test1];
}

UIview xib 类:-=--------

#import "FirstView.h"

@implementation FirstView
@synthesize textview;

-(instancetype)initWithCoder:(NSCoder *)aDecoder{

if (self = [super initWithCoder:aDecoder]) {

[self loadingView];
}
return self;
}

-(instancetype)initWithFrame:(CGRect)frame{

if (self = [super initWithFrame:frame]) {

[self loadingView];
}
return self;
}

-(void)loadingView{

textview.text = @"You are required to call in advance to schedule transportation. Time frame requirements are 48 hours for Anthem and 72 hours for MHS.\n\nYou will always need the Medicaid and Social Security number of the member who has an appointment.\n\nAll eligible members can schedule appointments up to 45 days in advance. For example, if you have existing appointments within the next 6 weeks from the current calendar date, you can schedule transportation to those appointments today.\n\nThere is only 1 adult allowed per trip. Any additional riders will need to be verified “medically necessary” by the facility representative. If a child has an appointment both parents are allowed to ride along.\n\nYou will ALWAYS need the physical address of the facility that you are going to AND the name of the doctor you will be seeing.\n\nThere is only one pick-up and one drop-off per scheduled trip.";
}

@end

最佳答案

您好,请告诉我您是如何创建该 View Controller 的,我不会让您调用 UIView xib 。您需要做的是使用 xib 创建一个类,然后将 UITextView 放在该类上,并实现 TextView 的委托(delegate)方法来执行输入文本时的任何操作。

关于ios - 如何在ios的mainView Controller 中加载xib文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35433396/

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