UITableView - Add subview to cell content view on row selection - iphone

How can I add an UIView as a subview in a cells contentView when the user has tapped the cell, and remove the same UIView when the user taps that cell again?
I am trying to make a list of photos in a UITableView with expand/collapse button. The UIView that I want to add is the container of photo's information. Instagram accomplished it, but I cant figure out how to do it
Please help me guys :)
Thanks!!!

I don't think you want to add a subview to the cell, but you want to add another cell to the already existing table. This way, you can achieve an "expand/collapse" feel to your table by using insertRowsAtIndexPaths:withRowAnimation:
Good luck!

Adding and removing the views in the cell should be easy enough inside didSelectRow, but you may need to keep track of which rows are in what state (big or small) by recording that in a mutable array. The bigger issue you will have is adjusting a cell's height, but look here for that.

Related

UIImageView and UItextView inside TableView

I'm working on iOS RSS app, and my last view, which is a UIViewController, is similar to the attached image. I inserted in my DetailView.xib, one Image View to pass the images of the RSS feeds and two Text View to pass the title and summary respectively.
The question is, how can i make the same, but inside a UITableview?
you can use custom cells for it and can add this custom cell at particular index. At first index you just add image view and at second index you just add textview.
Check out this pretty good tutorial Custom UITableViewCell Using Interface Builder.
i hope it helps you.
You can achieve this particular thing by using Custom Table View Cell.
Table View gets created using single Table View Cell again and again. It is much more efficient and uses less memory.
You should check this tutorial.
I hope it will help you.
Thanks
You can make TableView height UITableView.automaticDimension and make sure UITextView autoscroll is disabled and constraint should be leading, trailing, bottom and top.
Here's the link this might work for you:
How to make a UITextView Expand with the text like the Notes app

Xcode Adding multi image in a table cell that can scroll Horizontal

Im making a restaurant app that allow me show 1 restaurant with many images in a table cell. I know how to customize the table cell.
Problem is I dont know how to add many picture into a table cell that can scroll Horizontal to view the image one by one. I added a scrollview in a table cell then add image inside the scroll but it not work when i scroll the image.
Can anybody help to give me some hint to do this?
Thanks so much,
Quang
Add a UIScrollView on top of the UITableViewCell, then fill the scroll view with images. There are plenty of tutorials on the interwebs about how to do this.

Custom cell in UITableView

I am making a custom cell which has text fields and as a result the custom cell is greater than the size of the iphone screen.But i am not being able to do horizontal scroll to reach the end of the cell.
I have tried using viewController and adding table view to it as well as creating table view controller and adding custom cell to it.
when doing it through TableViewController,I am not able to horizontally scroll it,whereas i am not getting how to add Custom cell class to the tableView object placed in viewController.I know that UITableView is a subclass of UIScrollView but not able to implement it.Please help.
Thanks
as per the documentation at
A table view in the UIKit framework is limited to a single column
because it is designed for a device with a small screen. UITableView
is a subclass of UIScrollView, which allows users to scroll through
the table, although UITableView allows vertical scrolling only.
so as desired in your case you will have to take some other approach. Now using Custom cell with TextFields should not actually need you to require Horizonatl scrolling. If the text is really large you would like to consider using TextView instead of TextFields.
Hope it helps
Ideally, you should be truncating your text. But if it is important for you to display the entire text, add a scroll view as a subview (or set it as the content view) and add your labels to the subview. Each cell will then be individually horizontally scrollable.

Let tableview's last cell scroll to half way up the screen

I have a tableview with custom cells. Each cell has a UITextfield. When the last cell's textfield is clicked, the keyboard pops up and covers it and the table view won't scroll up any further. Is there a property of UITableview that can be set so that the last cell can scroll to half way up the screen?
Thanks in advance
There are a two ways to approach this (that I can think about off the top of my head):
You can use the tableFooterView property of UITableView to set an arbitrary, empty view to be about half the size of your table.
You can add empty cells to the bottom of your table
Both of these approaches will accomplish roughly the same thing, but using the tableFooterView property is probably your best bet.
see Making a UITableView scroll when text field is selected for a list of solution..
Also basing your view controller from UITableViewController (since you say its a table) will provide all this functionality automatically!

Allow input in a UITableViewCell

So I have a UITableView (its in a UIPopOverController if that matters), and I want the user to be able to edit the content of the tableView. I added a UINaviagationController, the tableView also has a title and an edit button. Essentially what I'm asking is, when the user taps the edit button, how can I add like UITextViews to some of the tableViews and in one of the cells, a UISegmentControl and a UITextView.
Thanks in advance
just add them as subviews of the cell, set correct frame to make subviews inside the cell