簡體   English   中英

如何在iOS的mainView控制器中加載Xib文件

[英]how to load xib files in mainView controllers in ios

對於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

嗨,您能告訴我您是如何創建該視圖控制器的,但我不會打電話給UIView xib。 您需要做的是使用xib創建一個類,然后將UITextView放在該類上,並實現文本視圖的委托方法以對輸入文本執行任何操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM