哈哈哈嘿嘿嘻嘻 2015-10-12 08:07 采纳率: 0%
浏览 2352

ios UIView中的UIButton不能点击按钮

.h文件

import

@interface HUPrompt : UIView

.m文件

import "HUPrompt.h"

import "UIView+Layout.h"

@implementation HUPrompt

UIImageView *backView = [[UIImageView alloc] init];

backView.frame = self.frame;
backView.image = _backImage;
[self addSubview:backView];
self.button = [[UIButton alloc] initWithFrame:CGRectMake(0, label.bottom+23, 74, 32)];

self.button.isPercentSize = YES;
self.button.backgroundColor = Btn_COLOR;
[self.button setTitle:@"知道了" forState:UIControlStateNormal];
[self.button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[self.button addTarget:self action:@selector(cancle1) forControlEvents:UIControlEventTouchUpInside];
self.button.titleLabel.font = TextSize;
self.button.layer.cornerRadius = 15;
self.button.layer.masksToBounds = YES;
[backView addSubview:self.button];
self.button.isHorizontalCenter = YES;
-(void)cancle1{

NSLog(@"sdfdsfds");
}

然后我在uiviewController调用 能显示 frame是传进来了的 但是不能点击 没触发事件 我想是不是uiview中不能用addTarget这个方法啊 求解答

  • 写回答

5条回答 默认 最新

  • LUCKEYMAN 2015-10-12 08:58
    关注

    你的button是加在imageview上面,加在self上面试试看。

    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作