How to prevent cell turnaround effect? - ios

I'm sorry about I can't upload images because of my low reputation point.
(Screenshots)
http://twitter.com/hseongeon/status/410214108881907712/photo/1
http://twitter.com/hseongeon/status/410214156785029120/photo/1
In most iOS development cases, turnaround effect appears on cells by selecting themselves.
As you can see in my screenshots, however, sometimes the effect make a view's background color and text color what I don't want to be. (like badgeView in my screenshots)
I'd like not to change my badgeView's color when cells are selected.
How to do this?
Thank you in advance.

Set the property selectionStyle on your cell to UITableViewCellSelectionStyleNone. This will prevent any calls to setSelected or setHighlighted on your cell.

Related

UISearchController search result cell background color

My UISearchController displays search results in UITableViewCells with background colour that I have not set
I can see by debugging the views that this grey colour is that of the cell.contentView. However, it doesn't react to me setting
cell.contentView.backgroundColor = [UIColor whiteColor];
in tableView:cellForRowAtIndexPath: method.
Are there any other methods to override that strange grey colour?
Are you able to provide an example project that reproduces your scenario? What does the tableView:cellForRowAtIndexPath: look like? If so, we can probably be much more helpful in determining the issue.
Without knowing specifics, it might be worth trying to set the contentView's backgroundColor in tableView:willDisplayCell:forRowAtIndexPath:, which occurs a bit later than tableView:cellForRowAtIndexPath:
It may also be worth making your own subclass of UITableViewCell so that you can better control the coloring of the cell.

Background color of cell with UITextView in UICollectionView

This is something i have been trying for past few days but not able to make a breakthrough
I have a textView in each cell of a UICollectionView.What i would like to do is to have a different color for only the first row of the grid.
I have used the solution from the below link from rob mayoff and it works fine for a label but not a textView
How do I alternate a UICollectiveViewCell's background color based on row?
I can see that the UITextView is superseding the UICollectionViewCell properties.
Any idea how can this be achieved?
Thanks.
i think i made some progress here. i have set the background color of the textview to clearColor . in this way, the color of the the collectionviewcell shows up.
I am not sure whether this is the correct approach

How do I make a UITableViewCell separator show up?

I'm having a similar problem to this question: UITableViewCell separator not showing up.
However, the proposed solutions don't work for me. Specifically, I've checked the following:
My UITableViewCell subclass does not override drawRect:.
I don't have a custom UITableView and, therefore, I'm not overriding layoutSubviews.
In Interface Builder, I have the Separator attribute of the Table View set to "Single Line".
I've tried programmatically setting tableView.separatorStyle to UITableViewCellSeparatorStyleSingleLine.
But still the separator line will now show up… Does anyone know of something else that could cause this behavior or have any ideas for how I might track down what is hiding/removing the separator line?
EDIT:
Well I feel silly… In trying to create the screenshot requested by valheru, I noticed that the lines ARE there, but are almost exactly the same color as the background, so I couldn't see them until the screenshot was blown up. I had suspected earlier that the separator color might be the issue, and I tried testing for that by setting the separator color to white (my background is almost black), but it turns out that there was some copy/pasted code that was programmatically resetting the color to the almost-invisible color.
Thanks valheru for leading me to the answer. :-)
Check the height of your table view's row and the height of the cell. Make sure that the row's height is not less than the cell's height.

Change custom cell's background without IB

I'm overloading my brains on this one.
I've created a table, which contains custom cells (one of a kind). A few days back, I changed the background to the grey you can see in the picture below here.
Now I don't know how I did that....
I don't think I did this programatically... What else would explain the color in IB?
I also searched my sourcecode, and the line for coloring the cell through code is commented out.
I need to reproduce this coloring on other custom cells. How the heck did I do this? :D
Ah, I thought of the answer while getting a cup of coffee:
Change the tableView's background (so, an other .xib-file) to the grey color to get that effect...

UITableView row count like iOS Mail app

How do you add counts inside of a UITableView UITableViewCell like the iOS Mail app?
In addition to DDBadgeViewCell (mentioned by #micpringle), there's also TDBadgedCell.
I tried out both and found TDBadgedCell to suit my needs more, as it puts the badges over the cell's text rather than under it, meaning the badges are visible even for cells with long texts.
The project also seems to be (currently, at least) more active than DDBadgeViewCell. (That being said, there seems to be a bug in the non-ARC version of TDBadgedCell.)
Create a custom UITableViewCell, position the labels where you want them (title, subtitle, count, whatever you need). I highly recommend Matt Gallaghers custom UITableView code - it takes a lot of the headaches out of dealing with custom rows. You'll have to follow Matt Gallaghers steps for customizing the cell.
To get the appearance of the count label as close as possible to your example (mail.app), you'll have to set the UILabel backgroundColor to gray (or whatever color you want it to be), textColor to white, and layer.cornerRadius to something equal to half the height of the label (if label is 20 high, cornerRadius should be 10). This will result in a UILabel with white text, gray background, round corners. Note - this isn't the most efficient method of doing this, but Apple hasn't put up the WWDC session video where they explain the performant method better (I missed that session).
The easiest solution would be to set an UILabel as accessoryView or using a custom UITableViewCell subclass which could be designed using IB.
I'd recommend creating a simple rounded UIView and a UILabel as a subview in it. I'd probably create a UITableViewCell subclass to manage the content.
Definitively the most easy way would be using a ready-to-use class like TDBadgedCell

Resources