I have related items in adjacent table cells. When either of the related items is selected, before going to the detail view, I would like the momentary cell selection highlight to show both (or in some cases 3) cells highlighted to alert the user of the relationshp.
This a purely a "nice to have" cosmetic feature.
Any help appreciated.
In the method called when the user selects a row you can use:
[cell setSelected:YES];
One way to get the cell would be using tableView:cellForRowAtIndexPath method (correct me if I'm wrong).
* FOLLOW-UP TO Shaggy Frog *
I appreciate your comments.
For some reason, I can't add a comment to or edit my own original question so I am editing my follow-up.
May I have an opinion on the following. Since the 2 highlightd cells would always be adjacent and the data related, it makes sense that the detail view contain details for both cells. However your point is valid and I don't want to get rejected.
Instead of 2 cells, if for the "related cells" I were to double the height of those cells, draw a horizontal line half way between (to make the 2 "subcells" of 44 pixels in height looking just like 2 cells) and place the data in subviews so the result looks exactly the same as 2 cells but it would actually be 1 cell. Selection of one of my "subcells" would then highlight 2 "subcells" which is the entire cell - same effect but 1 cell.
Do you think that would pass?
And of course the biggest advantage is that I know how to do this versus the multi-cell highlighting which doesn't seem possible.
Related
I've created a UITableViewCell with a textfield in it, which has a large diffused shadow underneath it. I've also set it up so that these big shadows can blend under its surrounding cells.
NB. Shadow has been HEAVILY emphasised here to show the problem.
The problem is that I want the shadow from my EMAIL textfield to blend underneath the password cell. i.e. I want both textfields to have a white background, but underneath them both I have the shadow. Something like this:
The reason this is a problem is because the UITableView is being rendered with upper cells "above" the lower ones. So any shadow from the cell at row 1 will bleed on top of the cells in rows 2, 3, 4 etc.
I was wondering if perhaps there is a way to change this rendering, and instead reverse the rendering so that a cell in row 4 is actually ABOVE rows 3, 2 and 1.
Or perhaps there is a way of setting the Password textfield so that no shadows are rendered on top of it?
Any help, very much appreciated!
Thanks to #Amr for pointing me in the direction of the cell.layer.zPosition.
The higher the value this is, the "closer" to the viewer the layer sits, so as long as each row has a higher value, it will appear "above" the shadows from any cells around it.
Since I use multiple sections in my code, I used this line to assign each cell above the previous one.
cell.layer.zPosition = CGFloat(indexPath.section) * 1000 + CGFloat(indexPath.row)
I was asking here about the option to make a collectionView with multiple cells since our cells have a different appearance for different indexs.
The answer was not sufficient because other then just create multiple cells and pick one for every index, you have all sorts of problems such as :
How can you register multiple classes ? collectionView.register(FlowViewCell.self
Reusable cells system gets crazy because they are different
Every action you do on a cell must be identified with its class and it becomes a mess.
So, I am searching for another way to do so with a single cell.
What would be a good way to set different buttons in the same position of a cell, and show/enable a different button with different indexes ?
So for index 1 I have 2 circle buttons, and for index 2 I have one large wide button? if you just put them on the same spot and hide one you get a strange design.
The answer you linked is what you are looking for.
We use 4 different types of cell in our app and we don't have any problem with it.
You don't have to register multiple classes, you can all create them in your storyboard (inside the collectionview), the system will register the classes for you.
And then you call the cells like explain in the answer.
The hard part is having different sizes, we only have two (large cell and square cell, so two square cells fit on the same level), more than that would be tricky, especially different height.
But apart from that you can have different content on each cell without any problem.
I would like to build a TableView where when the user clicks on a cell it expands to show more information. My question is how do I use Autolayout to arrange the multiple items in each cell.
Each cell will always be the same size, whether it is collapsed or not, so the sizing isn't dynamic.
The first problem I have is how to use Autolayout to arrange all the items in the cell. Before Xcode 7 I was successfully using Autolayout where I would pick a label-button-view to arrange, click Editor > Align > Trailing/Leading/Top Space, to.. etc. This is now greyed out and I don't know how to replace my old strategy.
Each cell has two rows of items. The first row shows all the time, the second only shows on collapse. Below is a picture of how the cell will look when it is collapsed:
The first row is a bit trickier because outlet1 and outlet 2 will have variable sizes. I would like 'label' to come right after label1, no matter how long or short that outlet happens to be. As arranged currently, there is a variable amount of space between the two.
What I'm looking to achieve in row 1 is basically exactly like Venmo:
Notice how 'paid' conforms to the size of the two names in the first row.
The second row has two buttons and an outlet which will always be the same size.
To sum up - how can I layout these elements in the UITableView for iphones4 thru 6S - and then how do I make this cell a collapsible cell? The construction of these cells seem to work as a system, not isolated from the whole - which is why this is a 2-part question.
is this what you want to achieve?
I'd like to use a UItableView to show a day Calendar. Each row corresponds to one hour. I need to show the hour between 2 cell of my tableview.
Like this :
(source: free.fr)
And this is my UITableViewCell :
(source: free.fr)
In the first screenshot, it works perfectly but if I scroll down then scroll up, my time label is cut like this :
(source: free.fr)
Have you any tips to figure out this problem using a tableView ?
The way you lay out your cell now is fragile, because the order of painting the cells on screen matters a lot. Try moving the content up so that your buttons are flush with the top of the cell, and the time label fits into the cell entirely. Add a thin header view to your table to make the top cell appear normal. Keeping the content of a cell entirely within its bounds should help you maintain reasonable scrolling speeds.
EDIT : You could also put a second clipped label at the top of your cell, and make its content identical to that of the label in the prior row. You would need to take special care to hide that label in the top row, but otherwise this should make your table immune to changes in the rendering order of its cells.
Make the background color of your cell clear. As you scroll up the z ordering of your cells get reversed and the lower cells overlap the higher ones causing this clipping.
I have the following:
I would like to make it so that the tableview stops right at the "So" cell, instead of having all the blank cells under it (the big plan is to have a bunch of multiple choice questions like the one in that pic, all on top of one another on one scrollview). I'm guessing I need to set the tableView's frame, but I was wondering if there was an easy way to calculate at runtime the exact height of the portion of the tableview where the cells are implemented (the ones with text in the pic). It's tricky because I made it so that each cell's height can change to accommodate the amount of text in it. Anyone have any advice?
There are two appproaches you can take.
Best and easiest.
1. Add a footer view to the table so it will not draw the rows after the last row. a blank footer view will do.
//Add empty view to hide trailing row seperators
UIView *emptyView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 0)];
emptyView.backgroundColor = [UIColor whiteColor];
[tableView setTableFooterView:emptyView];
[emptyView release];
2.Check how many rows you have in the tableview and calculate the tableheight and change the frame of table view.
There isn't a tableView:sizeOfAllCells: function if that is what you are looking for. From your question it sounds like you to adjust the size of your table so you can put other content on bottom of it.
You are correct is saying that you want to alter your UITableView's frame property to match the height.
[table setFrame:CGRectMake(0,0,table.frame.size.width,heightOfCells)];
There are a few things you could do though. If you had an array of all the cells, you could loop through it real quick and add the height of each of them. You could (I don't particularly recommend it though) loop though the number of sections and rows you have, using tableView:cellForRowAtIndex: instead of having an array of cells, and get the heights that way. If each cell is the same height (sounds like its possible it wont be) you could just do some simple math to figure out the height. Lastly, you could keep a dictionary or array of heights and update it in the tableView:cellForRowAtIndex: so if the content changes, it updates the size, but then you would have to call a reloadData. Those are just a few ideas of ways to solve this particular problem.
Here's a hack (so wait to see if a better solution comes along):
Use numberOfSections to get the number of sections (if you later change to grouped style), and then add up the heights of rectForSection: for each of the sections (in plain style, just take rectForSection:0). Maybe add a bit to this for the separators.