Ios 为什么要为textView设置文本在textView的底部添加文本?
我是目标c中的noob,我创建了一个页面xib文件,该页面有一个文本视图为空。 我将UITextView拖到此页面并连接到self outlet。 现在我想添加这样的文本,我是JANATAN。当我使用这段代码并运行我的模拟器时,我的模拟器会显示我的文本视图,但我看到我的句子是文本视图的最后一行!!! 为什么?这是我的形象: 这是我的代码:Ios 为什么要为textView设置文本在textView的底部添加文本?,ios,xcode,textview,uitextview,Ios,Xcode,Textview,Uitextview,我是目标c中的noob,我创建了一个页面xib文件,该页面有一个文本视图为空。 我将UITextView拖到此页面并连接到self outlet。 现在我想添加这样的文本,我是JANATAN。当我使用这段代码并运行我的模拟器时,我的模拟器会显示我的文本视图,但我看到我的句子是文本视图的最后一行!!! 为什么?这是我的形象: 这是我的代码: - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup a
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
getTextPlaces = [self CreateTextViews];
textField1 = [getTextPlaces objectAtIndex:0];
[self.view addSubview:textField1];
NSString *str = [_stack pop];
textArray = [self readInformationFromDatabaseWithData:str];
NSString *s1 = [[textArray objectAtIndex:0]objectForKey:@"Names"];
textField1.text = [NSString stringWithFormat:@"%@",s1]; //this s1 value is I am janatan
}
- (NSMutableArray *)CreateTextViews{
UITextView *tf = [[UITextView alloc] initWithFrame:CGRectMake(35, 70, 250, 50)];
tf.backgroundColor = [UIColor purpleColor];
tf.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
tf.autocorrectionType = UITextAutocorrectionTypeNo;
tf.textAlignment = NSTextAlignmentRight;
//tf.text=@"Hello World";
//second one
UITextView *tf1 = [[UITextView alloc] initWithFrame:CGRectMake(35, tf.frame.origin.y + 70, 250, 50)];
tf1.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
tf1.backgroundColor=[UIColor whiteColor];
tf1.autocorrectionType = UITextAutocorrectionTypeNo;
tf1.textAlignment = NSTextAlignmentRight;
//and so on adjust your view size according to your needs
NSMutableArray *twoText = [[NSMutableArray alloc]init];
[twoText addObject:tf];
[twoText addObject:tf1];
return twoText;
}
我的朋友,如果要删除此项,您需要设置以下内容:
self.automaticallyAdjustsScrollViewInsets = NO;
在viewDidLoad方法中。您应该在问题中包含产生此问题的代码。@EsaLakaniemi谢谢我的朋友,我添加了代码!!!