[英]UIbutton frame and addtarget is different
I make custom view and there create button add on view. 我进行自定义视图,并在视图上添加创建按钮。 In View Controller
In View控制器
MyCustomView *customView = [[MyCustomView alloc] init];
[customView.button addTarget:self action:@selector(goodTry) forControlEvents:UIControlEventTouchUpInside];
But if I touch my button in frame only down mean line is touchable, upper of mean line addTarget does not working. 但是,如果我在框架中触摸我的按钮,只有向下的中线是可触摸的,中线的上端addTarget不起作用。
----
|\ |
|*\ |
|**\ |
|***\|
----
-- It is my button frame. -这是我的按钮框。 Where
***
- it is working. ***
-在工作。 Where empty place doesn't work. 空旷的地方不起作用的地方。
Thanks for your help. 谢谢你的帮助。
为按钮添加背景色,并检查按钮的放置方式和位置。如果按钮位于自定义视图之外,则无法对该外部部分执行操作。
Check that your button frame lies inside the parent's frame. 检查按钮框是否位于父母的框内。 Area of button outside Parent's frame freezes and doesn't respond to touch events.
Parent框外的按钮区域冻结,并且不响应触摸事件。 Set
clipToBounds = YES;
设置
clipToBounds = YES;
on button to test it. 按钮进行测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.