objective-c - UITableViewCell 子类 - 在 IBAction 上添加 subview

标签 objective-c ios uitableview

当触发 View 内的 UITableViewCell 按钮时,我尝试将 subview 添加到 UIViewController 的 View 中。我面临的问题是从 TableView 单元格的子类调用父 View 。

最佳答案

您可以在 View 层次结构中查找父tableView:

-(UITableView*) parentTableView
{
    UIView* v = [self superview];
    while (v && ![v isKindOfClass:[UITableView class]]) {
        v = [v superview];
    }
    return v;
}

关于objective-c - UITableViewCell 子类 - 在 IBAction 上添加 subview ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11925331/

相关文章:

ios - 将 NSMutableArray 保存到 plist

iOS - 仅从一个表格单元格中删除 uilabel 或 uiimageview

ios - Quartz2D 在触摸时绘制点或线的好方法?

objective-c - 将视频添加到启动画面或应用程序的第一个 View 中(IOS xcode 4.0)

ios - 当用户使用 swift 单击 TableView 中的一个单元格时,如何立即运行计时器?

ios - Swift DateComponentsFormatter 删除前导零但在分钟位置至少保留一位数字

ios - 搜索栏和导航栏之间的空白 - Swift

ios - 获取图像后从其 imageView 刷新 UITableViewCell 布局

ios - 如何访问存储在数组中的对象的数据?

ios - tableView.tableHeaderView = UISearchDisplayController.searchBar;并调用 setContentInset : ; searchBar is not drawn when i scroll the table