您的位置:首页 > 移动开发 > IOS开发

button点击无反应

2016-06-27 19:58 519 查看
我的代码:
{
UIImageView *rjUnpBagV=[[UIImageView alloc]initWithFrame:Frame(0, 0, ScreenWidth, ScreenHeight)];
self.rjUnpBagV.backgroundColor=[UIColor whiteColor];
[self.view addSubview:self.rjUnpBagV];
UIButton *rjPublishBtn=[UIButton buttonWithType:UIButtonTypeSystem];
rjPublishBtn.frame=Frame(ScreenWidth/4, rjUnpImgV.frame.origin.y+rjUnpImgV.frame.size.height+10, ScreenWidth/2, 30);
[rjPublishBtn setTitle:@"发布职位" forState:UIControlStateNormal];
[rjPublishBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[rjPublishBtn setBackgroundColor:[UIColor colorWithRed:0.33 green:0.79 blue:0.76 alpha:1]];
[self.rjUnpBagV addSubview:rjPublishBtn];
[rjPublishBtn addTarget:self action:@selector(rjPublishBtnAction) forControlEvents:UIControlEventTouchUpInside];
}
-(void)rjPublishBtnAction{
    NSLog(@"点击");
}


btn不能点击的原因-----父视图没有开用户交互的话,子视图也不能点击

UIImageView是需要开用户交互的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  iOS