0

请帮忙..我的子类中有这个按钮,当我在我的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];

该按钮出现但不可点击:(

4

1 回答 1

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];

}
于 2013-04-09T09:06:21.847 回答