ios - 添加按钮不在 tableView 上添加新行

标签 ios objective-c xcode

我还添加了包含数组的 tableView 按钮,我希望当我单击添加按钮时,它会将 textField 的内容添加到将显示在 tableViewController 上的数组中

-(void) add:(UIButton *)sender{
    [tableViewController._myArray addObject:headerView._searchTextField.text ];
}

最佳答案

当您更新 tableview 的数据源时,您需要重新加载 tableview 以查看更新的更改,您缺少 tableview Controller 的 reloadData mehtod :-

-(void) add:(UIButton *)sender{
    [tableViewController._myArray addObject:headerView._searchTextField.text ];
    [tableview reloadData]; // considering tableview is you variable holding reference of UITableView
}

关于ios - 添加按钮不在 tableView 上添加新行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52204263/

相关文章:

objective-c - 子类化 NSFontManager 不起作用

ios - 如何像扫描图像一样调整彩色图像

ios - 如何在 Xcode 中隐藏警告

xcode - 如何在 iOS7 上设置状态栏样式以点亮内容?

ios - 将自定义 UIView 添加到 TableViewCell

ios - Alpha 在 UITableViewCell 中不起作用

ios - AVPlayerItemDidPlayToEndTimeNotification 在项目未完成播放时发布

iphone - iPhone 与 Android 上的 Web 应用程序性能

iphone - 从 xib 中提取 UI 项目?

iphone - xcode 构建 svn 号插入不起作用