Trying to position a UILabel above some text, but the elements are “stepping” on each other. I positioned them with x,y,h,w such that they should not do this but alas, they are. You can see in the screenshot that the label text “Abalone” and the text are commingled. What changes do I need to make here? I’ve already tried changing the x,y,w,h values to no great effect…

txtView = [[UITextView alloc] initWithFrame:CGRectMake(10,20,280,300)];
[txtView setFont:[UIFont fontWithName:@"ArialMT" size:14]];
txtView.text = word.definition;
txtView.editable = NO;
txtView.scrollEnabled = YES;
[txtView scrollRangeToVisible:NSMakeRange([txtView.text length], 0)];
txtView.minimumZoomScale = 1;
txtView.maximumZoomScale = 10;
UILabel *wordTitle = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 250, 20)];
wordTitle.text = word.term;
[txtView addSubview:wordTitle];
[detailsViewController.view addSubview:txtView];
I think the problem is you are adding the label view as a subview to
UITextview. You have to reserve some space for the label view in theUITextview. You can either add some padding to the textView, which can be confusing, because padding inUITextViewis not constant and varies based on the font size. Or you can add yourUILabeldirectly to thedetailsViewController.viewand start yourUITextViewbelow the label.Hope it helps.