uitableview

How to add a UITableView as a subview to a UIView in xib?

可紊 提交于 2020-01-17 04:15:27
问题 I have a custom view that I built using xib file. In this custom view, there is a UIView where I would like to add a static UITableView as a subview. The UITableView to be shown here is present on the storyboard and associated to a UITableViewController . I did the following: let vc = (UIStoryboard(name: "Main", bundle: nil)) .instantiateViewControllerWithIdentifier("tableController") as! TableController vc.loadViewIfNeeded() table = vc.table // this is an outlet, I'm sure it is not nil table

How to add a UITableView as a subview to a UIView in xib?

空扰寡人 提交于 2020-01-17 04:15:14
问题 I have a custom view that I built using xib file. In this custom view, there is a UIView where I would like to add a static UITableView as a subview. The UITableView to be shown here is present on the storyboard and associated to a UITableViewController . I did the following: let vc = (UIStoryboard(name: "Main", bundle: nil)) .instantiateViewControllerWithIdentifier("tableController") as! TableController vc.loadViewIfNeeded() table = vc.table // this is an outlet, I'm sure it is not nil table

Disable prepareForReuse for selected cell

不羁岁月 提交于 2020-01-17 04:14:09
问题 I have a custom UITableViewCell . When a cell gets selected, a UILabel gets added to it. I had to use prepareForReuse for it not to get messy, like so: - (void)prepareForReuse { NSArray *viewsToRemove = [self.view subviews]; for (UILablel *label in viewsToRemove) { [label removeFromSuperview]; } } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { CategorieCell *customCell = [tableView dequeueReusableCellWithIdentifier:@"cellID"

Why dequeue reusable cell twice in making custom table view cell

本秂侑毒 提交于 2020-01-17 04:09:04
问题 I am following a tutorial of making custom table view cell with storyboard. I drag a UILabel as subview of the cell and set its tag to 1. I have two questions regarding the data source code. What's the purpose of the second dequeue statement? I know it's an init method while not using storyboard to make the custom cell. What's the difference between tableview and self.tableview? -(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { static

tableview internal inconsistency when deleting

感情迁移 提交于 2020-01-17 03:54:31
问题 I have an array (datasource) with a set of addresses, my tableview is set to have double the amount of cells from the datasource so I can style the odd cells to be small and clear (to make the tableview look like the cells are separated by a small space). My problem comes when deleting a row, I do the following: -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{ [tableView beginUpdates]; if

Changing the UITableViewCell swipe action title

╄→尐↘猪︶ㄣ 提交于 2020-01-17 03:34:56
问题 I have a row action button titled "Activate". When I press it, I want the title to change to "Deactivate". I was unable to change the title in the handler function. Also, "Activate" and "Deactivate" should have different functions. func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? { let account = accountTypes[indexPath.section].accounts[indexPath.row] let delete = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title:

UINavigationController from scratch?

家住魔仙堡 提交于 2020-01-17 03:28:07
问题 I have a view based app that works well. (In other words, I'm not going to start over with a Navigation-Based App template.) It's an immersive app of sorts and I'm trying to add a Table View that loads in a new view when a button is pressed. The loading the nib part works, but I can't seem to be able to add a navigation controller to the new view. I want to see a navigation bar on top with a done button and an edit button. Also, I want to the Table View entries to be empty. I added a new file

Checkmarks in UITableViewCells showing incorrectly

早过忘川 提交于 2020-01-17 03:26:07
问题 I have a small scrollable tableView which displays roughly eight rows, when I select a row a checkmark appears, when I select it again it disappears. The issue is, as I scroll down and the cells are reused, more rows are automatically checked. What is the best practice for tracking which rows require a checkmark so that this does not happen. I have looked everywhere but haven't found Swift solution that works well. func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath:

CAGradientLayer has wrong position after scroll to top in UITableView. Swift

爷,独闯天下 提交于 2020-01-17 03:06:07
问题 I need to make a shadow on the bottom on the specific UITableViewCell . I made it but when I scroll to bottom it works fine, when I scroll to top the shadow has wrong position and it appears on the top of UITableViewCell . I tried several methods but it doesn't work for me. I read this question and this question How can I fix it? func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier

Dynamic viewForHeaderInSection and multiple cellForRowAtIndexPath

流过昼夜 提交于 2020-01-17 02:21:48
问题 I'm trying to make a custom cell to be the Section of my cells: For this I'm overriding some functions like: numberOfRowsInSection viewForHeaderInSection heightForHeaderInSection And I'm working with multiple cellForRowAtIndexPath I'm using a if indexPath.row to identify the Cell and populate them in a dynamic way. import UIKit class TesteTableViewController: PFQueryTableViewController { override func preferredStatusBarStyle() -> UIStatusBarStyle { return UIStatusBarStyle.LightContent }