Does this need to be invoked on the UI thread to work? Regards,
James On 21/08/2012, at 11:06 AM, Drew Greenwell < [email protected]> wrote: I actually initially thought about that and wrote this code below, but it also seems to have no effect. If I call cell.SetHighlighted(true, false); immediately after initializing the cell the highlight is on, but I need it to highlight only when the row is selected. I’m getting close to saying it can’t be done without a custom cell, but that seems wrong. public override NSIndexPath WillSelectRow (UITableView tableView, NSIndexPath indexPath) { selectedRowIndex = indexPath; tableView.CellAt(indexPath).SetHighlighted(true, false); return indexPath; } public override void WillDeselectRow (UITableView tableView, NSIndexPath indexPath) { tableView.CellAt(indexPath).SetHighlighted(false, false); } *From:* Craig Dunn [mailto:[email protected]] *Sent:* Monday, August 20, 2012 7:42 PM *To:* Drew Greenwell *Cc:* [email protected] *Subject:* Re: [MonoTouch] Setting HighlightedTextColor when UITableViewCellSelectionStyle.None is used 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 __________ Information from ESET NOD32 Antivirus, version of virus signature database 7403 (20120820) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __________ 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
