【问题标题】:iOS tableFooterView: Can't use UIButton?iOS tableFooterView:不能使用 UIButton?
【发布时间】:2010-11-25 18:51:46
【问题描述】:

我创建了一个自定义的UIViewController,其中包含一个UIImageView 和一个UIButton。在tableView viewForFooterInSection 方法中,我返回了视图,它显示正确(我可以看到按钮)。但是,我无法触摸按钮。它不会抑制/突出显示,并且我连接的 IBAction 不会触发。

另外,我有一个来自相机的物体,叫做takenPicture。 myImage 是 customView 的 UIImageView IBOutlet 属性。 imageView 总是空的。

我不确定我做错了什么,但这是我在viewForFooterInSection method 中的代码:

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

【问题讨论】:

    标签: iphone uitableview ios ios4 tableview


    【解决方案1】:

    听起来好像没有为您的视图(包含按钮和图像视图的视图)正确设置框架/边界。可能它默认为 CGRectZero,您可以看到按钮和图像的原因是因为剪裁已关闭。但如果按钮超出其父视图的范围,触摸事件将不会过滤到按钮。

    【讨论】:

    • 我使用 Interface Builder 创建了视图控制器,因此我拖放了 ImageView 和 UIButton。我没有以编程方式创建它或对 frame 属性做任何事情
    猜你喜欢
    • 1970-01-01
    • 2011-06-19
    • 1970-01-01
    • 2011-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多