Tag: uitableview

dynamictableViewCell的高度

我有一个内部的标签tableViewCell可能是多行高。 我已经将标签的Lines属性设置为0.但是,当我使标签的文本有多行时,文本被切断。 以下是我设置故事板的方法: 有人知道我是如何让桌子的单元格高到足以包含标签吗?

将“UITableViewCell”types的值转换为自定义单元格

我通常从来没有这个步骤的问题,但由于某种原因,当我重新设置我的故事板现在我有这个部分的代码问题: func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("Cell") as! UITableViewCell (cell as! TableViewCell).usernameLabel.text = friendsArray[indexPath.row] as String return cell } 我已经做了所有的明显的东西,如确保单元格标识符是“单元格”。 我的错误是这样的: 无法将types“UITableViewCell”(0x1094ada18)的值转换为“YOpub.TableViewCell”(0x106620410)。 编辑:问题是我有我的didLoad函数self.tableView.registerClass(UITableViewCell.self,forCellReuseIdentifier:“单元格”)。 删除这一行后,我的代码再次工作。

UITableView奇怪的布局行为在滚动上发生变化

我有一个UITableView自定义UITableViewCelldevise有自动高度。 行为是在UITableView UIViewController的第一次加载显示我的标签与部分文本。 然后当我滚动到底部,然后滚动到顶部,我得到所需的高度和文本的外观。 这里是截图: 初始查看视图控制器: 这里是滚动底部然后顶部(这是我的实现一些Lorem文本被我删除正确的外观): 编辑1: 码: tableView.rowHeight = UITableViewAutomaticDimension tableView.estimatedRowHeight = 101 // much heigher than most cells. But no use. 在UI生成器中,UITableViewCell的“行高”设置为“默认”(自定义未选中) 在UI生成器中,UITableView的“行高”设置为“101”(也尝试将其设置为“0”,但结果相同)。

如何在UITableViewCell中为UIButton设置Action

我有XIT文件TimerCell.xib与UITableViewCell 。 在cellForRowAtIndexPath的其他类中,我初始化这个UITableViewCell : static NSString *CellIdentifier = @"cellTimer"; TimerCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { //cell = [[TimerCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"TimerCell"owner:self options:nil]; cell = [nib objectAtIndex:0]; 在我的TimerCell中有两个UILabel和一个UIButton 。 对于这个button,我想设置一些方法的行动 。 我怎样才能做到这一点? 以及如何在第一个UILabel实时显示我的背景倒数计时器的数据?

UISearchView不显示search值

在我的TableView扩展点击sections.now我使用Uisearchbarsearch表中的部分…它给了我的UIsearchbar但search不能采取…我认为问题是在numberOfRowsInSection .please检查我得到错误的地方..为什么search栏不工作 – (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [self.mySections count]; } – (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSInteger rows = 0; if ([self tableView:tableView canCollapseSection:section] || (tableView == self.searchDisplayController.searchResultsTableView) ) { if ([expandedSections containsIndex:section] ) { NSString *key = [self.mySections objectAtIndex:section]; NSArray *dataInSection = [[self.myData objectForKey:key] objectAtIndex:0]; return [dataInSection count]; } return 1; } else{ rows = […]

如何解决“笔尖,但没有得到一个UITableView”的错误?

为什么我得到这个错误? 终止应用程序由于未捕获exception“NSInternalInconsistencyException”,原因:' – [UITableViewController loadView]加载了“pB1-re-lu8-view-o7U-YG-E7m”笔尖,但没有得到UITableView。 这里是我的代码: class FriendListTableViewController: UITableViewController{ var objects = NSMutableArray() var dataArray = [["firstName":"Debasis","lastName":"Das"],["firstName":"John","lastName":"Doe"],["firstName":"Jane","lastName":"Doe"],["firstName":"Mary","lastName":"Jane"]] override func viewDidLoad() { super.viewDidLoad() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } // MARK: – Table View override func numberOfSectionsInTableView(tableView: UITableView) -> Int { return 1 } override func […]

如何在UITableViewRowAction中添加图像?

我试图在UITableView滑动样式中添加图像。 我试着用Emoji文字和它的工作正常 func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? { let editAction = UITableViewRowAction(style: .normal, title: "🖋") { (rowAction, indexPath) in print("edit clicked") } return [editAction] } 但我需要图像而不是表情符号,同时我尝试了 editAction.backgroundColor = UIColor.init(patternImage: UIImage(named: "edit")!) 但它得到了重复的图像,我使用了许多格式的图像,如20 * 20,25 * 25,50 * 50,但仍然复制。 我如何添加图片?

iOS UITableView与dynamic文本和图像一起渲染(NSAttributedString +图像)

我的问题是这样的:我有iOS应用程序(如twits – 虽然这不是一个Twitter应用程序),包括文本和图像(主要是图标/表情符号和缩略图)的dynamic内容。 我想在表格行中同时渲染文字和图像。 这里的主要困难是每一行都会有不同的大小(使caching更难),我需要dynamic计算图像大小,以适应每个图像出现的文字(我可以像20个表情符号相邻+文本+更多表情符号+等)。 我一直在四处寻找,我已经尝试了一些方法。 我最初的想法是使用UIWebView。 我能够创build一个示例应用程序与每行一个UIWebView,甚至与一些“聪明的”NSCache预渲染的单元格性能不是很好,再加上我不得不处理UIWebView JavaScriptcallback找出内容何时正确加载。 我的第二个尝试是覆盖drawRect一个新的UITableViewCell。 在drawRect方法中,我使用NSAttributedString和NSSelectorFromString来设置每种内容(常规文本,粗体,斜体,不同颜色,图像)的范围。 为了适应我使用CTRunDelegateCallbackscallback(getAscent,getDescent,getWidth)的图像。 像这样的东西: CTRunDelegateCallbacks callbacks; callbacks.version = kCTRunDelegateVersion1; callbacks.getAscent = ascentCallback; callbacks.getDescent = descentCallback; callbacks.getWidth = widthCallback; CTRunDelegateRef delegate = CTRunDelegateCreate(&callbacks, (__bridge void *)imgAttr); // img Attr is a Dictionary with all image info 有关这种方法的更多细节,请检查这个优秀的职位: http : //www.raywenderlich.com/4147/how-to-create-a-simple-magazine-app-with-core-text# 最后有两个问题: 这是最好的方法,我可以使这个performance好吗? 我想知道是否为每个滚动的每个单元格调用drawRect不会很麻烦 – 有什么我可以提前做的吗? 我已经玩了一段时间了,但仍然是一个很大的滞后 – […]

如何在重新加载视图后保存tableView单元格的复选标记使用NSUserDefaults?

我是新来的iOS开发,我使用复选标记的UITableView单元格。 我想存储在NSUserDefaults数据库中检查过的单元格,当我重新加载应用程序时,选中的单元格将显示,我尝试不同的方式,但仍然无法实现它。 任何人都可以帮助我? 我将不胜感激。 对不起,我的英文不好。 我的代码如下: #import "FirstRowSubview.h" @interface FirstRowSubview () @end @implementation FirstRowSubview @synthesize array = _array; @synthesize lastIndexPath = _lastIndexPath; – (void)viewDidLoad { [super viewDidLoad]; NSMutableArray *list = [[NSMutableArray alloc] initWithObjects:@"ffgfgh", @"564654", @"56548", @"fgmjfgmf", @"ggkdj", nil]; self.array = list; [list release]; } – (void)viewDidUnload { [super viewDidUnload]; self.array = nil; } #pragma mark […]

如何存储用户数据的iOS

我需要存储用户可以添加的数据,他们可以添加无限量的数据。 它们可以是NSStrings或UIImage 。 我已经看了NSUserDefaults,但它似乎用于less量的数据,如设置或偏好。 什么是最好/最安全的方式来存储用户信息,以便当他们closures应用程序,它仍然在应用程序。 数据填充一个UITableView并且是一个NSMutableArray 。 最好的办法是做到这一点?