I’m trying to add a UIButton to a UIView but I’m getting this error at runtime.
NSInvalidArgumentException’, reason: ‘-[UIView addSubView:]:
unrecognized
XCode also warns me that that
Instance method ‘-addSubView:’ not found (return type defaults to
‘id’)
This is my code:
UIView *trackPaneView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 768, 100)] autorelease];
[trackPaneView setBackgroundColor:[UIColor blueColor]];
UIButton *testButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 10, 100, 30)];
[testButton setTitle:@"AWESOME" forState:UIControlStateNormal];
[trackPaneView addSubView:testButton]; //the error coming form this line
The method is
addSubview:not addSubView:(capitalisation error)