如何在ios中的mainView控制器中加载xib文件

时间:2016-02-16 13:03:46

标签: ios objective-c xib custom-view

我是iOS的新手,在我的应用程序中我在我的mainView控制器中加载UIView xib文件,在这个xib文件中我插入了一个UITextField但是当我在该文本中插入文本时它不适用请帮助我。

mainViewController: -

#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

1 个答案:

答案 0 :(得分:1)

您好,请您告诉我您是如何创建该视图控制器的,并且我没有让您调用series.Points(2).DataLabel.Text = "A:" & t1 & chr(13) & "B:" & t2 xib。 您需要做的是使用xib创建一个类,然后将UIView放在其上,并实现文本视图的委托方法,以执行输入文本时的任何操作。