请帮助..我的子类中有这个按钮,当我在我的uiview中添加它时,它无法点击,任何想法?谢谢
我的子类中的按钮:
- (void)configureDate{
ChangeButton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
ChangeButton.frame= CGRectMake(10, 20, 100, 30);
[ChangeButton setTitle:@"Change Date" forState:UIControlStateNormal];
[ChangeButton addTarget:self action:@selector(changeDate) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:ChangeButton];
}
我在我的uiview中添加了子类/按钮:
dateClass = [[DateClass alloc] init];
[dateClass configureDate];
[myView addSubview:dateClass];
[dateClass releaseTable];
按钮出现但无法点击:(
答案 0 :(得分:0)
试试这个:
[myView addSubview:dateClass];
[myView bringSubviewToFront:dateClass];
尝试为dateClass和ChangeButton按钮设置BG颜色以进行测试。
- (void)configureDate{
ChangeButton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
ChangeButton.frame= CGRectMake(10, 20, 100, 30);
[ChangeButton setTitle:@"Change Date" forState:UIControlStateNormal];
[ChangeButton addTarget:self action:@selector(changeDate) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:ChangeButton];
self.backgroundColor=[UIColor redColor];
ChangeButton.backgroundColor=[UIColor yellowColor];
}