简体   繁体   English

iOS tableFooterView:无法使用UIButton?

[英]iOS tableFooterView: Can't use UIButton?

I made a custom UIViewController with an UIImageView and a UIButton in it. 我制作了一个自定义UIViewController其中包含一个UIImageView和一个UIButton In the tableView viewForFooterInSection method I returned the view, and it displays correctly(i can see the button). tableView viewForFooterInSection方法中,我返回了视图,它显示正确(我可以看到按钮)。 However, I can't touch the button. 但是,我无法触摸按钮。 It won't depress/highlight, and my connected IBAction doesn't fire. 它不会压低/突出显示,我连接的IBAction不会触发。

Also, I have an object from the camera called takenPicture. 另外,我有一个来自照相机的对象,名为takedPicture。 myImage is a UIImageView IBOutlet property of customView. myImage是customView的UIImageView IBOutlet属性。 The imageView is always empty. imageView始终为空。

I'm not sure what I'm doing wrong, but here is my code that is in the viewForFooterInSection method : 我不确定我做错了什么,但这是我在viewForFooterInSection method中的代码:

self.customView = [[CustomView alloc] initWithNibName:@"CustomView" bundle:nil];
customView.myImage.image = self.takenPicture;
return customView.view;

It sounds as if the frame/bounds isn't set correctly for your view (the one containing the button and image view). 听起来好像没有为您的视图(包含按钮和图像视图的那个)正确设置框架/边界。 Likely it is defaulted with CGRectZero, and the reason you can see the button and image is because clipping is off. 可能它是默认的CGRectZero,你可以看到按钮和图像的原因是因为剪辑已关闭。 But touch events wont filter up to the button if it is outside the bounds of its superview. 但触摸事件不会过滤到按钮,如果它超出其超级视图的范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM