I’m having a problem with this basic code:
-(id)init{
self = [super init];
if(self){
self.mensaje = [[UILabel alloc]initWithFrame:CGRectMake(100.0, 100.0, 100.0, 100.0)];
[self.mensaje setText:@"He vuelto"];
[self.view addSubview:self.mensaje];
[self.mensaje setHidden:YES];
}
return self;
}
All the code works fine, except [self.mensaje setHidden:YES];. The Label is always shown at start.
I hope could help me, this is basic, but necessary!!
Good luck!
This code is in the wrong place. You shouldn’t be creating and working with views in the initializer of a view controller (assuming the above code is inside a view controller class).
instead, do the following:
This also assumes you are using ARC. If not, you need to add
autoreleaseas follows: