Tag: Swift uitableview

EXC_BAD_ACCESS当我试图删除一个UITableView部分

我有这个代码: // – Update the data source self.order.persons.removeAtIndex(index) // – Disable the user interaction self.tableView.userInteractionEnabled = false // – Delete the needed section from the table view let sectionIndexSet = NSIndexSet(index: self.order.persons.count – 1) self.tableView.beginUpdates() self.tableView.deleteSections(sectionIndexSet, withRowAnimation: .Automatic) self.tableView.endUpdates() // – Update the table view with a delay to update all the indexes NSTimer.scheduledTimerWithTimeInterval(0.3, handler: […]

从细节屏幕返回时,UITableView单元格消失

我似乎无法弄清楚为什么会发生这种情况。 我有一个自定义单元格,在堆栈视图中显示一系列UIViews的tableview。 很简单的布局。 然后我有另一个viewcontroller,我正在使用tableview中的任何选定的项目的详细信息页面。 当你点击桌面单元格时,它将把它推到导航控制器堆栈上打开详细视图。 当你按下tableview的选定单元格现在已经不见了。 但是,您仍然可以点击所在的区域,然后再次打开详细信息页面。 这就像不透明度被降低到0或什么东西。 IB中的select风格也设置为none。 这是主视图控制器: import UIKit class PaletteTableViewController: UITableViewController { let cp1 = ColorPalette(colorsInPalette: [ColorView(color: UIColor.red, frame: CGRect.zero), ColorView(color: UIColor.purple, frame: CGRect.zero), ColorView(color: UIColor.gray, frame: CGRect.zero), ColorView(color: UIColor.green, frame: CGRect.zero)]) let cp2 = ColorPalette(colorsInPalette: [ColorView(color: UIColor.black, frame: CGRect.zero), ColorView(color: UIColor.blue, frame: CGRect.zero), ColorView(color: UIColor.brown, frame: CGRect.zero), ColorView(color: UIColor.red, frame: […]

上一个和下一个键盘button使用静态UITableView上的UITextfields

我正在使用带有静态单元的UITableView来显示带有几个UITextFields (每个具有从9000到9015唯一的有序标记)的窗体。 当我select一个UITextField ,键盘显示出一个具有2个button的UIToolbar ,上一个和下一个。 只要在屏幕上绘制前一个或下一个UITextField ,button就可以正常工作,否则我无法select它,因为viewWithTag找不到字段。 DEMO: http : //s15.postimg.org/5xjsoiupl/ezgif_com_video_to_gif.gif 编辑:我IQKeyboardManager使用IQKeyboardManager但它有相同的错误。 如果单元格不可见,那么它们不会被检测到,因此下一个或上一个箭头被禁用。 UITextFields let numberToolbar = UIToolbar(frame: CGRectMake(0, 0, self.view.frame.size.width, 50)) numberToolbar.barStyle = UIBarStyle.Default numberToolbar.tintColor = color_green prev_keyboard_button = UIBarButtonItem(title: "Previous", style: UIBarButtonItemStyle.Plain, target: self, action: "keyboardPrevButtonTapped:") next_keyboard_button = UIBarButtonItem(title: "Next", style: UIBarButtonItemStyle.Plain, target: self, action: "keyboardNextButtonTapped:") numberToolbar.items = [ prev_keyboard_button, next_keyboard_button, UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, […]

核心数据加载Swift后asynchronous刷新UITableView

我有一个UITableView, tViewNews 我有一个刷新function,从我的服务器下载数据,将其存储到核心数据,然后表视图从核心数据加载这些数据。 它完美的作品 func refresh(refreshControl: UIRefreshControl) { self.newsArray = [NewsItem]() self.newslists = [[NewsItem]]() self.getNewsFromServer() self.getNewsFromCoreData() self.tViewNews.reloadData() refreshControl.endRefreshing() } 现在,当用户第一次打开新闻viewDidLoad() ,我希望表视图首先从核心数据加载,然后从服务器asynchronous填充我的表视图数组(使用与刷新函数完全相同的方法)和然后重新加载表视图。 所以我已经在我的viewDidLoad()函数中尝试了下面的代码。 override func viewDidLoad() { super.viewDidLoad() // Getting news from Core Data getNewsFromCoreData() // Updating core data from server and populating table view from core data dispatch_async(dispatch_get_main_queue()) { self.newsArray = [NewsItem]() self.newslists = [[NewsItem]]() […]

通过单元格内的textView的内容更改单元格高度

我有一个名为todoTableView的表视图与用户创build的单元格。 每个单元格都有文本视图。 我想通过文本视图的内容来改变单元格的高度。 这是我试过的: func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell: TableViewCell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath:indexPath) as! TableViewCell cell.bounds.size.height = cell.textView.bounds.size.height return cell }

UITextView和单元格根据textview的内容dynamic更新高度?

我一直在自定义单元格内的UITextView问题。 除了我的问题,textView完美的工作。 我有UITextViewDelegate方法设置,所以当发生什么事情的TextView,我有这些方法连接。 我想知道如何让我的自定义单元格dynamic增加它的高度,因为用户键入。 一旦用户点击了文本视图的行的末尾,也让textview自动添加另一行。 我在网上search了一段时间,这个问题的大部分例子都是客观的。 没有太多的快速代码。 我将不胜感激任何帮助。 我有我的单元格连接在桌面视图文件中。 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell: cellCustom = the_TableView.dequeueReusableCellWithIdentifier("cell") as! cellCustom return cell } 在自定义单元格文件中,我设置了代表… func textViewDidChange(textView: UITextView) { } func textView(textView: UITextView, shouldChangeTextInRange range: NSRange, replacementText text: String) -> Bool { return true } 我曾尝试过一些… self.textview.sizeToFit() self.the_TableView.rowHeight = UITableViewAutomaticDimension self.the_TableView.estimatedRowHeight […]

如何使用swift在表视图中实现延迟加载图像

我想用我的表视图使用swift延迟加载概念。 在我的表格视图中,我显示了包含产品图像和产品名称的多个单元格。 请帮助我获得解决scheme。