Sorry, a beginner’s questions:
I have created an instance of an UILabel and would like to add copies of this UILabel to 4 different views. I tried the following code, but it won’t work as I am assigning the UILabel to one view and then assign it to the next — which results in the UILabel being removed from the first view. This carries on, so I end up with the UILabel being assigned only to the very last view:
UILabel *titleTitle = [[[UILabel alloc] initWithFrame:CGRectMake(120, -48, 100, 28)] autorelease];
titleTitle.text = @"Index";
titleTitle.textColor = [UIColor blackColor];
titleTitle.backgroundColor = [UIColor clearColor];
titleTitle.font = [UIFont fontWithName:@"Ballpark" size:25.0f];
[indexView addSubview:titleTitle];
[indexView2 addSubview:titleTitle];
[indexView3 addSubview:titleTitle];
[indexView4 addSubview:titleTitle];
How can I manage to assign copies of UILabel to my views?
This is probably overkill for your needs, but if you must copy a complex object, then archiving and unarchiving it should work: