tableviewcell

Swift, Auto Resize Custom Table View Cells

无人久伴 提交于 2019-12-01 00:29:31
In my app, I have a table view with an image, label and text view in each cell. I would like to be able to auto-resize the cells depending on the amount of content in the text view. (The text view is the lower most text.) So far, I have added the correct constraints; leading, trailing, top and bottom to the text view and have disabled scrolling and editing. In my tableViewController.swift file, I have written this code: override func viewWillAppear(_ animated: Bool) { tableView.estimatedRowHeight = 100 tableView.rowHeight = UITableViewAutomaticDimension } However, this is not working as when I

dequeueReusableCellWithIdentifier always return non nil?

痞子三分冷 提交于 2019-12-01 00:11:34
In the classic pattern below the returned cell from dequeueReusableCellWithIdentifier is always non nil . Why? Shouldn't we have to allocated some cell first then we can have some to be reused? I am using a customize cell and it was created in the storyboard. (However, if I had used the default UITableViewCell ,the phenomena is same - the returned cell is still always non-nil ). Enviroment: Xcode 4.3.3 iOs 5.1 AlbumListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AlbumCell"]; //cell always non nil --- why?? if(cell == nil){ cell = [[AlbumListCell alloc] initWithStyle

Swift, Auto Resize Custom Table View Cells

橙三吉。 提交于 2019-11-30 20:39:17
问题 In my app, I have a table view with an image, label and text view in each cell. I would like to be able to auto-resize the cells depending on the amount of content in the text view. (The text view is the lower most text.) So far, I have added the correct constraints; leading, trailing, top and bottom to the text view and have disabled scrolling and editing. In my tableViewController.swift file, I have written this code: override func viewWillAppear(_ animated: Bool) { tableView

presentViewController from TableViewCell

Deadly 提交于 2019-11-30 07:41:23
问题 I have a TableViewController, TableViewCell and a ViewController. I have a button in the TableViewCell and I want to present ViewController with presentViewController (but ViewController doesn't have a view on storyboard). I tried using: @IBAction func playVideo(sender: AnyObject) { let vc = ViewController() self.presentViewController(vc, animated: true, completion: nil) } Error: Value of type TableViewCell has no member presentViewController Then, I tried self.window?.rootViewController!

Reloading UITableView shows error?

一个人想着一个人 提交于 2019-11-29 13:04:59
I am in a strange situation . when i try to reload the tableview using reloadData() it shows the following error . . . fatal error: unexpectedly found nil while unwrapping an Optional value Here is the web service method that retrieves output func didRecieveOutput(results:NSArray) { if results.count != 0 { userOrders = results as! NSMutableArray dispatch_async(dispatch_get_main_queue(), { () -> Void in self.orderList.reloadData() }) } } Edit : I had checked my connection as well as delegate & datasource . It works fine with static data . But problem came when I called reloadData(). I had the

How to display dynamically data from Server in CollectionViewCell in TableViewCell with swift3?

瘦欲@ 提交于 2019-11-29 12:27:26
I got my json link data from TableViewCell , and then retrieve that data from server and display in collectionView with related TableViewCell data. How to display this data in swift3? Please, help me. I got url link (mainThemeList.main_associated_url,main_name) from TableViewCell. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let mainThemeList = mainHomeThemeTable[(indexPath as NSIndexPath).row] let cell = tableView.dequeueReusableCell(withIdentifier: "homecell") as! HomeCategoryRowCell DispatchQueue.main.async { cell.categoryTitle.text =

Unable to make view equal width to cell in iOS?

拜拜、爱过 提交于 2019-11-29 11:27:02
I am making a custom cell in iOS.I have added prototype cell.I m trying to add a view inside a cell of equal width to parent cell.But the width of cell is not equal please tell me how should i do it? Constraints are: View structure: EDIT: In preview on iPad it does not show complete view .But on actual device it works fine.Why? sample here https://drive.google.com/file/d/0B7RGQm8-8k24Q0tXUFZOLUZFQk0/view?usp=sharing As I checked your sample project I found that You made your viewController size to iPhone4.7 inch ...and I checked the source code of storyboard and I found that targetRuntime="iOS

presentViewController from TableViewCell

最后都变了- 提交于 2019-11-29 05:20:10
I have a TableViewController, TableViewCell and a ViewController. I have a button in the TableViewCell and I want to present ViewController with presentViewController (but ViewController doesn't have a view on storyboard). I tried using: @IBAction func playVideo(sender: AnyObject) { let vc = ViewController() self.presentViewController(vc, animated: true, completion: nil) } Error: Value of type TableViewCell has no member presentViewController Then, I tried self.window?.rootViewController!.presentViewController(vc, animated: true, completion: nil) Error: Warning: Attempt to present whose view

How can I fix crash when tap to select row after scrolling the tableview?

丶灬走出姿态 提交于 2019-11-28 12:53:43
I have a table view like this: when the user tap one row, I want uncheck the last row and check the selected row. So I wrote my code like this: (for example my lastselected = 0) func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { var lastIndexPath:NSIndexPath = NSIndexPath(forRow: lastSelected, inSection: 0) var lastCell = self.diceFaceTable.cellForRowAtIndexPath(lastIndexPath) as! TableViewCell var cell = self.diceFaceTable.cellForRowAtIndexPath(indexPath) as! TableViewCell lastCell.checkImg.image = UIImage(named: "uncheck") cell.checkImg.image = UIImage

How to display dynamically data from Server in CollectionViewCell in TableViewCell with swift3?

喜夏-厌秋 提交于 2019-11-28 06:31:05
问题 I got my json link data from TableViewCell , and then retrieve that data from server and display in collectionView with related TableViewCell data. How to display this data in swift3? Please, help me. I got url link (mainThemeList.main_associated_url,main_name) from TableViewCell. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let mainThemeList = mainHomeThemeTable[(indexPath as NSIndexPath).row] let cell = tableView.dequeueReusableCell