1
我在目標c的noob,我創建一個頁面xib文件,該頁面有一個textView爲空。 我在此頁面拖動UITextView並連接到自我插座。 現在我想添加像這樣的文字「我是JANATAN」。當我使用這段代碼並運行我的模擬器時,我的模擬器向我展示了我的textView,但是我看到了我的句子是textView的最後一行! 爲什麼?這是我的形象:pic of simulator爲什麼setText爲textView添加文本底部的textView?
這是我的代碼:
- (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;
//[email protected]"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;
}
你應該在你的問題中包含產生這個問題的代碼。 –
@EsaLakaniemi謝謝我的朋友,我添加了我的代碼! – user3599133