I'm trying to display an image with a tableView like so (see image below).
But I'm not sure about the way to implement the red part :
is the red part in the header part of the table view ?
is the red part outside of the table view ?
is this in a custom cell ?
PS : Note that the tableView I would like to be with the picture would have various sections.
Thank you very much for the help.
In this case it's either a header or a custom UITableViewCell because it scrolls with the table. You can implement it either way.
Personally I'd start by making it a cell. That will allow you to use autolayout to easily tackle sizing and dynamic type.
create a custom view as per suthar's comment and add it to the tableview headerview ,
if you have more than one sections than u can use the groupped tableview instead of plain tableview...it becomes more easy..
Related
I am trying to understand how to structure different components within rows and sections. So my question are
1.would the top view,imageview and the components under it be separate cell or a single cell within a section.
2.What if one section does not have a imageview or a certain component. Would we just hide that view or would it be in a separate cell and that wont be called. And if hiding is the solution, how would you remove the space.
I am looking for just an abstract answer nothing specific. Just to understand how to structure views in tableviews
You pull all in one cell. For hiding any view (image, button, etc),
Put top content, image and comments on stack view.
Whenever there is no image, use imageView.hidden = true
Image space should automatically disappear.
Refer to this link for more elaborate tutorial
It depends on the preference of the developer. If you want a more flexible and easy to update/adjust view you can create a separate cell/nib file for that view. Additionally you can create it on one cell only but be careful because updating of design/view/content won't be easy.
If the imageview does not have a value I suggest that you always put a placeholder for that imageview so that the user will know that the image is not fetched.
I am just thinking. Suppose, i have a tableview which have custom cell. It's simple. But My idea is that, when i click a tableview cell then another tableview is appear under that tableview cell, and again i click that cell then that sub tableview disappear. Similarly when i click second cell than work same. Is it possible? Please Provide me any idea or reference.
This is entirely possible, you're talking about Expandable cells.
My example here
The general idea is that your custom cell has a tableview at the bottom of the cell, and what you do is just change the cell height to display said tableview, on tap.
It's not easy, I'm not gonna lie it took us a while to do it, but we managed, and I'm telling you, it's very possible.
You can find a lot of help using the Expandable Cell keywords.
Note that you're gonna find yourself handling a lot :
What to do when the expanding cells is shown off screen?
What to do when you're expanding the first/last cells ?
What to do when expanding another cell ?
What to do when scrolling inside that cell (a scrollview inside a scrollview !)
There are many cases where it'll work, but won't work fine, and there is gonna be a lot of fine tuning. Specially in our case where we have rounded corners, but only when the cell is expanded, and not in cases where it's the last or first cell (next to section header).
They look cool and make you feel proud, but don't say to your PM it'll be done in a week, because it's a pain to build.
If you want to show additional cell information, you can add more cells after the cell indexpath you have clicked.
Create a custom table view cell classCustomTableViewCell by subclassingUITableViewCell class. And system will generate CustomTableViewCell.h, CustomTableViewCell.m, CustomTableViewCell.xib files for you.
Add protocols UITableViewDataSource and UITableViewDelegate in your CustomTableViewCell.h and implement the required methods in CustomTableViewCell.m files
Add a method for setting datasource and use the datasource for updating the table.
NOTE:
Handle table-dequeue mechanism properly, otherwise you will end up
with weird issues that may take time to investigate and resolve.
If you use this custom cell for all the cells in your parent table then the gestures will only listened by the child table. So plan for that too.
Please visit my blog for the sample code. https://myioslearnings.blogspot.in/2017/03/nested-table-view-in-ios-objective-c.html
In iOS, the built-in contacts app looks similar to what's displayed on this example page. What controls are being used to create the initial view? Is it a table view? If so, how is the image on the left offset from the two rows?
What's happening behind the scenes to switch this view into edit mode? Are labels being replaced with textboxes or are the textboxes simply being set to editable?
There are 2 ways to do things like this that I know
#1. That is UI TableView, but TableView with a custom TableView Header.
Also it is UITableViewStyleGrouped
Just Init and setup the view include a UIImageView On the left side and three UITextField on the right side.
like this
|----------| |---TextField---|
|---Image--| |---TextField---|
|----------| |---TextField---|
and set this view with:
self.tableview.headerView = yourViewWithImageAndTextField;
2. Just try to use Apple's own ABPersonViewController
Apple's sample
Documentation
Good luck to you
This looks like an pre iOS7 UITableView in UITableViewStyleGrouped style, and a probably a custom cell to handle the image.
This question already has an answer here:
TableView like the Contacts app in the iPhone
(1 answer)
Closed 9 years ago.
How can i make a tableview like the contacts app,
the main problem is how to place correctly the photoHolder like this :
I give you suggestion that actual UITableView should be Start at 'Telephone' and remain cell such like 'nome', 'Sobrenome' and 'Usuaroi' and also 'photo' taken BOX its all are create on custom UIView.
After Custom view is created then create your UITableView Wich Have groped style and it all customize by UILabel and UITextField.
Interesting.
Never tried such a thing.
If it is really a table ...
I'd try a custom cell for the first 3 cells of which I'd try to change the frame. (Move to the right and make it smaller. But code it in a flexible way. No constants. Use offsets from the right and left margin of the table view.
Then I'd try accessing the table view itself, which in the end is not much more than a subclass of UIScrollView and add a UIImageView as subview exactly there where the photo goes.
Give it a try and have fun ...
Another suggestion:
The first section of the grouped table, the one with the photograph to the left, is not the first section of the table. It is the table header view.
This table header view contains of an UIImage view and a UIcontrainer view. That UIContainer view has a table in it. That scroll view's property is set to not scrollable.
May not be the best idea but looking at the design, it coud work.
Just ... I am not sure how that top left table reponds to scrolling gestures. Touches (selections etc) should work fine.
I'm working with autolayout and its been going very well so far but right now I am at lost as to the way to proceed to achieve the design I want.
I got a a small questionnaire with 2 sections. Each section is embedded in its own UIView with each section's view containing an uiview per question.
My problem is, I want to add the question dynamically, say only show question 2 of section 1 when the user enter a certain input in question 1.
I first attempted to show each section by using using addsubview for the question view and reseting the frame of the section dynamically using setFrame: before realizing this method was not gonna work properly with autolayout (for example, since my questionaire is contained in a scrollview, scrolling will call the loadsubviews method on the scrollview and reset the section's view to their original size...)
What would be the proper way to achieve this? Using a tableview with a variable size perhaps? Or programatically creating layoutconstraint?
What I ended up doing is Dan F suggestion of using a tableview. I used the answer in this great post https://stackoverflow.com/a/12574544/865632 to create static tableview in view container allowing me to have static cell uitableview without having to cluster my main view controller with dummy tablecontroller