我正在尝试将UIButton添加到UIView,但我在运行时收到此错误。
NSInvalidArgumentException',原因:' - [UIView addSubView:]: 无法识别的
XCode也警告我那个
实例方法'-addSubView:'找不到(返回类型默认为 'ID')
这是我的代码:
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
答案 0 :(得分:5)
方法是addSubview:
而不是addSubView:
(大写错误)
答案 1 :(得分:2)
它是-addSubview
,而不是-addSubView
。方法名称区分大小写。