Xcode - UILabel does not change value to viewDidAppear

Hi everyone, I have an application for the iPhone that I am creating. It uses a uitableview, and this applies to the detail view.

Now in the detailed view, I have a scroll view, and all the data (XML) gets into it perfectly, no problem every time.

My UILabels in my scrollview do an update with the correct data, but they continue to add subviews to each other to add a label after the label, and it all looks useless.

I tried everything to try to remove the subheadings, for example:

for(UIView *subview in [scrollView subviews]) {
 [subview removeFromSuperview];
}

and

[[scrollView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];

So, I'm at a dead end, I had no idea what was going on. Any help? I’ve been searching Google for ages and out of date, but keep looking for the same answers that don't work :(

, , .

!

, :

- (void)viewDidAppear:(BOOL)animated {

 // Create the scroll view for this view
 UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
 scrollView.contentSize = CGSizeMake(320, 270);
 [scrollView setFrame:CGRectMake(0, 198, 320, 170)];

 // Do the labels for the text
 UILabel *dates = [[UILabel alloc] initWithFrame:scrollView.bounds];

 dates.textColor = [UIColor whiteColor];
 dates.font = [UIFont boldSystemFontOfSize:12];
 dates.text = round_date;
 dates.tag = 1;
 [dates setBackgroundColor:[UIColor clearColor]];
 [dates setFrame:CGRectMake(10, 10, 280, 22)];
 [scrollView addSubview:dates];
 [dates release];

 // Add the content to the main scrollview
 [self.view addSubview:scrollView];
 [scrollView release];

}
+3
1

, , viewDidAppear , .

,

-(void) viewDidLoad;

.

, , UIViewController

-(void) viewDidLoad {
    scrollView = [[UIScrollView alloc] initWithFrame];
    [self.view addSubview:scrollView];
}

:

UIScrollView *scrollView;
0

Source: https://habr.com/ru/post/1784965/


All Articles