2

So in my iOS app I have a menu designed like this:

enter image description here

The Images are created with the following code:

cell.imageCell?.image = menuItems[indexPath.row].image
    cell.imageCell.image = cell.imageCell.image?.withRenderingMode(.alwaysTemplate)
    cell.imageCell.tintColor = MenuTableViewController.fontColor
    cell.imageCell.backgroundColor = UIColor.clear

This code is placed in the tableview cellForRowAt function. Now all the different viewcontrollers(HomeViewController, InfoViewController etc...) have no access at all to the menu controller and thus are not able to change the color of the image and nowhere else am I changing the color of these images. Now when I press one of the tabs that don't use any Alerts or modal views like home or info, the images stay perfectly fine, however when I press on Weather or excursions which download a json file with URLSession dataTask and display an alert telling to please wait, the images turn grey like the following:

enter image description here

I'm not sure how this is even possible that one viewcontroller can change another viewcontrollers subviews. Thanks in advance -Jorge

J.Paravicini
  • 621
  • 10
  • 29
  • 2
    Perhaps what you see is a dimmed presentation of your icons. Don't use image templates or set `tintAdjustmentMode` to `normal` to stop fading icons. Usually that happens if you display alert or modal controller. – Ben Affleck Feb 16 '17 at 16:28
  • You are right it wasn't the URLSessions problem, it was the alert telling to please wait that changed the color, and setting the `tintAdjustmentMode` to `normal` did the trick. If you want to post an answer i'll accept it as the right one. – J.Paravicini Feb 16 '17 at 18:13
  • glad I guessed it right. I have posted an answer below. Thanks – Ben Affleck Feb 16 '17 at 22:14

2 Answers2

15

Perhaps what you see is a dimmed presentation of your icons. Don't use image templates or set tintAdjustmentMode to normal to stop fading icons. Usually that happens if you display alert or modal controller.

Ben Affleck
  • 11,374
  • 5
  • 50
  • 74
1

It looks like its the default UITableViewCell click style. Try to set the style to none, as answered here: How can I disable the UITableView selection highlighting?

Swift:

cell.selectionStyle = UITableViewCellSelectionStyle.none
Community
  • 1
  • 1
Lirik
  • 2,948
  • 27
  • 30
  • If you feel that this question is a duplicate, flag it as such. It's generally a bad practice to duplicate answers. – JAL Feb 16 '17 at 15:58
  • 1
    @JAL its not a duplicate, he described a certain problem, and i suggested a solution. the link above just shows how to do it. – Lirik Feb 16 '17 at 16:10