代码之家  ›  专栏  ›  技术社区  ›  Daddy

iOS tableFooterView:无法使用UIButton?

  •  0
  • Daddy  · 技术社区  · 15 年前

    我做了个习惯 UIViewController 用一个 UIImageView 以及 UIButton 在里面。在 tableView viewForFooterInSection 方法返回视图,并正确显示(我可以看到按钮)。但是,我不能按这个按钮。它不会降低/突出显示,并且我的连接IBAction不会启动。

    另外,我有一个相机里的物体叫做takenPicture。我的形象是 UIImageView视图 customView的IBOutlet属性。imageView总是空的。

    我不知道我做错了什么,但我的代码在 viewForFooterInSection method :

    self.customView = [[CustomView alloc] initWithNibName:@"CustomView" bundle:nil];
    customView.myImage.image = self.takenPicture;
    return customView.view;
    
    1 回复  |  直到 11 年前
        1
  •  2
  •   TomSwift    15 年前

    听起来好像没有为视图(包含按钮和图像视图的视图)正确设置帧/边界。很可能它是CGRectZero的默认值,而您可以看到按钮和图像的原因是因为剪辑处于关闭状态。但是,如果触控事件不在其超级视图的范围内,则它不会过滤到按钮。

    推荐文章