0

In iOS 11, UITabbarItem conforms to UISpringLoadedInteractionSupporting which defines the isSpringLoaded var. In WWDC 2017 session 203, they indicate all you need to do to enable spring loading is set isSpringLoaded to true on a control, and dragging an item to it will trigger the action.

This works fine for UIButton. But I can't get anything to happen with UITabbar. I have a completely canned TabBarController in my storyboard. I set

tabBarItem.isSpringLoaded = true

...for the viewController I want to spring load. Dragging the item over that item does nothing.

I can't find anything in the docs to indicate what else should be done.

jeffro37
  • 696
  • 6
  • 16

1 Answers1

0

I've been working on this today and finally found the solution.

For some reason enabling the isSpringLoaded property from the storyboard doesn't work so what I done was I enabled the isSpringLoaded property from code.

A quick solution to enable all UITabBarItems to have springLoading is

 override func viewDidLoad() {
    super.viewDidLoad()
    tabBarController?.tabBar.items?.forEach({ (item) in
        item.isSpringLoaded = true
    })
}

This works on Xcode 9.0 beta 4 (9M189t)

stringRay2014
  • 636
  • 1
  • 11
  • 29
  • I actually tried this exact thing earlier, because I observed that same thing (works in code, not storyboard) for a UIButton. But this didn't work for me there, and even taking your code exactly it still doesn't work. Maybe the prob is that I'm dragging a TableViewCell in this case? Hadn't thought about it, but maybe that's not possible (tho TV -> TV certainly is) – jeffro37 Aug 03 '17 at 04:50