As written in the title, I have a property to a UITextField
. I add this UITextField
to the UIView
.
If I have a strong pointer, the UITextField
appears,
If I have a weak pointer, the UITextField
doesn't appear.
What goes wrong when I have a weak pointer? I did the same with UIButton
and then it actually appears (with strong and weak pointer).
Here's some code:
CreateCategoryView.h
@interface CreateCategoryView : UIView
@property (weak, nonatomic) UITextField *nameTextField;
@end
CreateCategoryView.m
@implementation CreateCategoryView
- (id)initWithFrame:(CGRect)frame andParent {
self = [super initWithFrame:frame];
if (self) {
self.nameTextField = [[UITextField alloc] initWithFrame:CGRectMake(5, 30, 310, 25)];
self.nameTextField.borderStyle = UITextBorderStyleRoundedRect;
self.nameTextField.textColor = [UIColor blackColor];
self.nameTextField.backgroundColor = [UIColor whiteColor];
[self addSubview:self.nameTextField];
}
return self;
}
@end