What about

cell.Highlighted = true; // no animation
or
cell.SetHighlighted(true,false); // optional animation

? I'm not really sure what effect you are trying to accomplish with this
code... if it is just to have different colors on every second row, why not
just set the TextColor directly inside your if-else?


On Tue, Aug 21, 2012 at 6:39 AM, Drew Greenwell <
[email protected]> wrote:

>  Hey all, I’ve got a UITableViewCell that I want to change the
> HighlightedTextColor. Setting the HighlightedtextColor property only seems
> to work when UITableViewCellSelectonStyle is set to something other than
> None. Do I have to subclass UITableViewCell to get this to apply or am I
> just missing something?****
>
> ** **
>
> Here’s a trimmed down version of my GetCell method. Note: Setting
> SelectionStyle to anything but none makes the highlighted color show as
> expected when the row is selected****
>
> ** **
>
> public override UITableViewCell GetCell (UITableView tableView,
> NSIndexPath indexPath)****
>
>                                 {****
>
>                                                 // the row index****
>
>                                                 int row = indexPath.Row;**
> **
>
>                                                 var dRow = Rows [row];****
>
>                                                 // get a reusable cell
> instance and set the style****
>
>                                                 var cell =
> tableView.DequeueReusableCell (TableCellIdentifier + dRow.ViewName +
> dRow.Text);
> if (cell == null) {****
>
>                                                                 cell =
> InstantiateCell(dRow, UITableViewCellStyle.Subtitle, TableCellIdentifier);
> ****
>
>
> if(indexPath.Row % 2 == 0){****
>
>
> // setting this to anything but None shows the highlighted text color****
>
>
> cell.SelectionStyle = UITableViewCellSelectionStyle.None;****
>
>
> var label = cell.TextLabel;****
>
>
> label.TextColor = UIColor.Black;****
>
>
> label.HighlightedTextColor = UIColor.Yellow;
>
>
> }else{
> ****
>
>
> // setting this to anything but None shows the highlighted text color****
>
>
> cell.SelectionStyle = UITableViewCellSelectionStyle.None;****
>
>
> var label = cell.TextLabel;****
>
>
> label.TextColor = UIColor.Black;****
>
>
> label.HighlightedTextColor = UIColor.Yellow;                    ****
>
>                                                                 }****
>
>                                                 }****
>
> ** **
>
> Thanks in advance for any insight. ****
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 7403 (20120820) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch
>
>
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to