my friend for remove this you need is to set the following:
self.automaticallyAdjustsScrollViewInsets = NO;
in the viewDidLoad method.
题
I'm noob in objective c and I create one page xib file that this page have one textView empty. I drag UITextView ton this page and connect to self outlet. Now I want to add any text like this "I AM JANATAN" in it. when I using this code and run my simulator , my simulator show me my textView but I see my sentence is last line of textView !!! why??? this is my image : pic of simulator
this is my code :
- (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;
}
解决方案
my friend for remove this you need is to set the following:
self.automaticallyAdjustsScrollViewInsets = NO;
in the viewDidLoad method.