Ios UIButton在我添加UIlabel之前一直有效

Ios UIButton在我添加UIlabel之前一直有效,ios,objective-c,uibutton,uilabel,Ios,Objective C,Uibutton,Uilabel,我尝试给一个UIbutton添加标签,直到添加了一个UIlabel层 起初按钮看起来是这样的,后来我就这样把标签两边的空间填满了 单击任一按钮时,将记录以下错误报告: unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: <UIWindow: 0x7fe460e338d0; frame = (0 0; 320 480); opaque = NO; auto

我尝试给一个UIbutton添加标签,直到添加了一个UIlabel层

起初按钮看起来是这样的,后来我就这样把标签两边的空间填满了

单击任一按钮时,将记录以下错误报告:

unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: <UIWindow: 0x7fe460e338d0; frame = (0 0; 320 480); opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x7fe460e326a0>; layer = <UIWindowLayer: 0x7fe460e33d80>> 
错误日志是否暗示我可以做些什么来识别点击手势?还是尝试让UIButton做出响应更好

变化#1

当我使用setTitle标记按钮时,也会出现同样的问题

    [UIButton buttonWithType:UIButtonTypeSystem];
UIButton *helpButton    = [UIButton buttonWithType:UIButtonTypeRoundedRect];
helpButton.frame = CGRectMake(72.0f, 472.0f, 188.0f, 32.0f);
[helpButton setTitle: @"Transposed Dekany" forState: UIControlStateNormal];
helpButton.layer.cornerRadius = 10;
[helpButton.layer setBorderColor:[[UIColor whiteColor] CGColor]];
[[helpButton layer] setBorderWidth:0.5f];
[helpButton addTarget:self action:@selector(goToHelp) forControlEvents:UIControlEventTouchUpInside];

UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(0,0,188,32)];
[label.layer setBorderColor:[[UIColor whiteColor] CGColor]];
[helpButton addSubview:label];
[self.view addSubview:helpButton];
变化#2


“你的意思是,当你触到按钮外时,你会崩溃吗?”谢宾·科希:不完全是。当我触摸按钮上未被文本覆盖的区域时,它工作;当我触摸按钮上被文本覆盖的区域时,它崩溃。我刚刚检查了一下,如果我在按钮区域外触摸,没有错误报告,这是我所期望的。
    [UIButton buttonWithType:UIButtonTypeSystem];
UIButton *helpButton    = [UIButton buttonWithType:UIButtonTypeRoundedRect];
helpButton.frame = CGRectMake(72.0f, 472.0f, 188.0f, 32.0f);
[helpButton setTitle: @"Transposed Dekany" forState: UIControlStateNormal];
helpButton.layer.cornerRadius = 10;
[helpButton.layer setBorderColor:[[UIColor whiteColor] CGColor]];
[[helpButton layer] setBorderWidth:0.5f];
[helpButton addTarget:self action:@selector(goToHelp) forControlEvents:UIControlEventTouchUpInside];

UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(0,0,188,32)];
[label.layer setBorderColor:[[UIColor whiteColor] CGColor]];
[helpButton addSubview:label];
[self.view addSubview:helpButton];
    UIButton *helpButton           = [UIButton buttonWithType:UIButtonTypeCustom];
[helpButton setTitleColor:[UIColor whiteColor] forState: UIControlStateNormal];
[helpButton setTitle: @"^^^^^^^Help^^^^^^^^^" forState: UIControlStateNormal];
helpButton.frame               = CGRectMake(72.0f, 472.0f, 188.0f, 32.0f); //same width and height
helpButton.layer.cornerRadius  = 10;
[helpButton.layer setBorderColor:[[UIColor whiteColor] CGColor]];
[[helpButton layer] setBorderWidth:0.5f];
helpButton.clipsToBounds       = YES;
[helpButton addTarget:self action:@selector(goToHelp) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:helpButton];