I make custom view and there create button add on view. In View Controller
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.
----
|\ |
|*\ |
|**\ |
|***\|
----
-- 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. Set clipToBounds = YES;
on button to test it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.