Code=3072 “The operation was cancelled” when setting alternate app icon

后端 未结 2 1337
轮回少年
轮回少年 2021-02-20 16:44

I am trying to set an alternate app icon named MyIcon in my iOS app. I have a MyIcon.png image in my project bundle (not in my Assets folder) and it is

2条回答
  •  既然无缘
    2021-02-20 17:28

    I was getting this error because of two reasons,

    • First, I didn't do "Add Files to 'ProjectNameFoo'" by adding png file to project. Otherwise it didn't work. After that it started to see icon.
    • Secondly, I was getting this error because I was trying to change icon after in viewDidLoad. I don't why but it was giving me same error. When I try with a delay like the code below it was working whatever second I gave.

      override func viewDidLoad() {
          super.viewDidLoad()
      
          delay(0.01) {
              if foo().isFoo() {
                  print("")
      
                  self.changeIcon(name: "ColdRabbit")
              }
              else {
                  print("")
              }
          }
      }
      
      func delay(_ delay:Double, closure:@escaping ()->()) {
          let when = DispatchTime.now() + delay
          DispatchQueue.main.asyncAfter(deadline: when, execute: closure)
      }
      

提交回复
热议问题