SSCollectionViewItem selected state? - iphone

I am using SSToolkit and SSCollectionView. When I click a SSCollectionViewItem, I would like to darken the item so the user knows it has been pressed.
The documentation (http://sstoolk.it/documentation/Classes/SSCollectionViewItem.html) shows a setSelected and setHighlighted method, but I am not sure how then to change the appearance of my item.
Any help?

The answer is in the documentation:
Discussion
Highlights or unhighlights the item,
animating the transition between
regular and highlighted state if
animated is YES. Highlighting affects
the appearance of the items's labels,
image, and background.
Note that for highlighting to work properly, you must fetch the item's
label (or labels) using the textLabel
(and detailTextLabel) properties and
set the label's highlightedTextColor
property; for images, get the items's
image using the imageView property and
set the UIImageView object's
highlightedImage property.
A custom table item may override this
method to make any transitory
appearance changes.
SSCollectionViewItem

Related

Highlight controls programmatically

I have many controls like, image views, labels (UIControls), which have I wish to show like a dual mode controls. i.e. Based on my data, I have to set them either with image 1 or image 2 (for a image view), similarly with the label. I tried accomplishing this using the highlighted state properties of image view and labels. For the image view, I gave one image reference for highlighted and another for normal.
however when I programmatically set the highlighted property to yes, they are not toggling between them. Is there something I'm missing?
From the documentation:
Highlighted state of a control. A control enters this state when a
touch enters and exits during tracking and when there is a touch up
event. You can retrieve and set this value through the highlighted
property.
So, you don't set the highlighted property. Try setSelected.
Have you seen this related topic: Highlighting a UIControl subclass?
Use selected state instead. I think highlighted state is a transient state.
Try this out:
if([imgeview isselected]){
[imageview setselected:NO];
}else{
[imageview setselected:YES];
}

Reordering causing subview 's backround color to clear

I m having issue of table cells reordering. I have some views with some background color in cell contenview.
When we drag cell for reorder its making all view's color to clear color.
its a standard behavior as much i understand.
Is there any way to not affect subview color while reordering?
The default behavior is to allow the user to see though the cell to best determine where to drop it, so strongly consider that use case before implementing something else.
You could try overriding setHighlighted: or setSelected: on the cell (or any applicable
subviews like UILabels) to ignore any changes when the controller is reordering.

Set background color of the deletion control of a UITableViewCell

In an iPhone/iPad app, I'm using a UITableView to display a list of items that can be edited. I can successfully alternate the background color of the rows in my table view. However, when I turn on "editing mode" (i.e., display the deletion control), each cell appears to be shifted to the right, and the deletion control slides in from the left.
My problem is that the deletion control has a white background color. I'd like the background color of the deletion control to match the background color of my UITableViewCell.
How do I accomplish this?
One answer is to, in the getCellContentView function, where you create frames/labels and add them as subviews, add an additional label that is much wider and starts with a negative X value. Then, this can be colored. Since it's drawn "underneath" the deletion control, the color shows through.
The trick is to understanding that the deletion control isn't drawing "white" anywhere. The deletion control itself's background color is already clear, so you have to fit something underneath. Negative "x" value does the trick.
Try setting the background of the accessoryView which houses the delete button to UIColor clearColor. I'm not sure the exact syntax, but something like:
[tableView.editingAccessoryView setBackgroundColor:[UIColor clearColor]];
If that doesn't do it for you, you may try setting the background of the entire tableview to clear. This should not affect your customized colors for each cell.

Clarify undocumented behavior of UITableViewCell on highlight event

UITableViewCell modifies the contents of it's contentView hierarchy when the cell is is highlighted (user touches down on the cell).
Two examples I've found to date:
Put a UIView in a cell's contentView with a background color. That UIView's background color is removed when the table cell is highlighted (it's apparently set to have a clear background.)
Put a UIButton in contentView. When the cell is highlighted, the button is also forced into the highlighted state.
It's as if there's some logic in the UITableView cell that inspects all views in the cell's hierarchy and modifies them according to a set of mysterious rules, then restores them back to normal once the cell is un-highlighted.
Can anyone explain what and why UITableViewCell is modifying (unexpectedly and in an undocumented fashion) in the contents of my custom table view cells?
Thanks!
The highlighting of the UITableViewCell is documented in the Apple docs as follows:
The highlighting affects the
appearance of labels, image, and
background. When the the highlighted
state of a cell is set to YES, labels
are drawn in their highlighted text
color (default is white). The default
value is is NO. If you set the
highlighted state to YES through this
property, the transition to the new
state appearance is not animated. For
animated highlighted-state
transitions, see the
setHighlighted:animated: method.
Note that for highlighting to work
properly, you must fetch the cell’s
labels using the textLabel and
detailTextLabel properties and set
each label’s highlightedTextColor
property; for images, get the cell’s
image using the imageView property and
set the UIImageView object’s
highlightedImage property.
This does not mention UIButtons, but this post is about how to prevent the button from going into the highlighted state when the cell does.

Resize UILabel text with swipe to delete

I am having some trouble getting my application to properly resize the text of UILabels when the user does a swipe to delete or other type of delete. Currently, the delete button is covering up the text that is in the cell (if it is really long). I would like for them to operate like how SMS (move clipped text down a line) or iPod (delete button resizing text).
I am using a custom UITableViewCell I am working with two labels, UIImageView and a couple of subviews for backgroundView and selectedBackgroundView. I have been playing with the springs and struts of the labels in the cell and partially attained my desired effect however, the text has a weird, quick resizing bug where it becomes deformed and stretched out and then is returned proper size when the delete button is done animating.
As far as other things that I have tried, I have made sure that my text does not adjust-to-fit and I have made my minimum font size the font size that I set for the label. I have also tried over-riding layoutSubviews but that didn't seem to have any effect at all.
If a screenshot (of the deforming label) or code would be helpful, I can post both but since nothing I have done is working, I figured they would be of little value.
fixed it by setting the "mode" of the label in the view panel to "left"
It sounds like you need to set the number of lines property and the wrap property for the labels.
If your actively changing the size of the label itself, you might want to animate that change.