Tag: tableview

iOS 11浮动TableView标题

有一个应用程序与多个部分,每个部分几行时,“展开”,没有“折叠”时。 每个部分都有一个section header,正在使用UITableViewHeaderFooterView的子类等来重用它们。 然后在iOS 11中: 描述问题的屏幕截图 我使用了可视化debugging器,并确认这是我的部分标题浮动。 标题下面的所有行显示正确,其他标题显示正常。 为了恢复理智,我抛出了头部的所有重用逻辑,并以编程方式进行编程。 彼此彼此。 所有在iOS 11之前的工作,仍然在iOS 11中浮动。漂浮的部分似乎每次都会改变,所以就是这样。 有任何想法吗?

继续从dequeueReusableCellWithIdentifier得到零?

我在故事板文件中创build了一个标识为“mainViewTableCell”的原型单元格,并将主表视图与名为“NTTableViewController”的自定义控制器类相连接。 我在NTTableViewController.m中实现了“tableView cellForRowAtIndexPath”函数,如下所示: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString* MAINVIEW_CELLIDENTIFIER = @"mainViewTableCell"; UITableViewCell *newCell = [tableView dequeueReusableCellWithIdentifier: MAINVIEW_CELLIDENTIFIER]; if (newCell == nil) { newCell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleSubtitle reuseIdentifier: MAINVIEW_CELLIDENTIFIER]; [newCell autorelease]; newCell.selectionStyle = UITableViewCellSelectionStyleNone; } NTContactItem* currentItem = [self.contactItemContainer objectInContainerAtIndex: indexPath.row]; NSString* firstName = currentItem.firstName; NSString* lastName = currentItem.lastName; NSString* […]

将Table更改为Edit模式并删除普通ViewController中的行

我只是将一个表插入一个普通的UIViewController中,并将委托和源组件连接到文件的所有者。 一切正常,当我插入数据到表行。 但现在我正在试图找出如何删除行。 我只是看了很多其他的post,但找不到合适的解决scheme。 我试图为表中的每一行插入一个断言button: cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 我甚至发现按下附件button时会调用的方法: – (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{ NSLog(@"Accessory pressed"); //[self tableView:tableView willBeginEditingRowAtIndexPath:indexPath]; //[self tableView:nil canEditRowAtIndexPath:indexPath]; //[self setEditing:YES animated:YES]; } 在日志内部打印消息,但没有任何一个我试图调用的方法(注释之一)确实将视图更改为编辑模式。 我怎么解决这个问题? 这里是UIViewController的屏幕截图。 我还没有集成一个navigationController。

Swift – tableView只有在滚动或切换展开/折叠后才能更新行高

我从这里使用CollapsibleTableView并根据我的要求修改它以实现可折叠的部分。 这是现在的样子 。 由于根据UIdevise我的部分有一个边框,因此我select了部分标题作为我的UI元素,该元素以折叠模式和展开模式保存数据。 原因:我尝试过但是无法在下面解释的模型中使用它 – **在节标题中有我的标题元素,并在其单元中的每个项目的细节。 默认情况下,该部分处于折叠状态。 当用户点击标题时,单元格被切换到显示。 正如我所说,因为有一个边框,需要显示整个部分(tapped header和它的单元格),所以我selectsection header作为我的UI元素的操作。 这是我的代码为tableView – func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return sections.count } func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { switch indexPath.row { case 0: return sections[indexPath.section].collapsed! ? 0 : (100.0 + heightOfLabel2!) case 1: return 0 case 2: return […]

iOS删除一个tableview行

我有我的应用程序在iOS 6上正常工作。随着升级,我停止能够从我的UITableView删除行。 我在原型单元中有一个button。 这是button的function: – (IBAction)deleteCell:(id)sender { UIButton *btn = (UIButton*) sender; UITableViewCell *cell = (UITableViewCell*) btn.superview.superview; NSIndexPath *indexPath = [_tableView indexPathForCell:cell]; if([names count] > 9) { int index = indexPath.row; [names removeObjectAtIndex:index]; [photos removeObjectAtIndex:index]; [_tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight]; } } 问题是我的索引variables始终为0。 我试了另一个解决scheme – (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { […]

(Swift)将数组存储和检索到NSUserDefaults

我正在尝试将数组存储到NSUserDefaults并在需要填充UITableView时检索数组。 目前我正在使用: //store data NSUserDefaults.standardUserDefaults().setObject(myArray, forKey: "\(identity.text!)listA") NSUserDefaults.standardUserDefaults().synchronize() //retrieve data let tabledata = NSUserDefaults.standardUserDefaults().stringForKey("\(identity.text!)listA") myArray = [tabledata!] tableView.reloadData() 但是我明白了 致命错误:意外地发现nil而解包一个可选值 当试图加载数据。 我不确定问题是在存储还是在检索中。 有没有人通过这个之前呢?

滚动时,UITableView复选标记消失

我必须做一个tableView的复选标记,但如果我滚动和一个检查标记单元格是不可见的,我滚回复选标记消失。 运行此代码时 var boolArray = [Bool]() func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { var cell:UITableViewCell = tableView.cellForRowAtIndexPath(indexPath)! if cell.accessoryType == UITableViewCellAccessoryType.Checkmark { cell.accessoryType = UITableViewCellAccessoryType.None boolArray[indexPath.row] = false } else { cell.accessoryType = UITableViewCellAccessoryType.Checkmark boolArray[indexPath.row] = true } println(boolArray) } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { boolArray.append(false) var view = UITableViewCell(style: UITableViewCellStyle.Default, […]

如何在swift中从另一个视图控制器重新加载tableview

当我解雇一个模式视图控制器我希望桌面更新,我使用iPad上的表单演示样式,所以viewWillAppear和viewDidAppear方法将无法正常工作