2 Replies
      Latest reply on Aug 8, 2019 7:05 AM by KMT
      adlibber Level 1 Level 1 (0 points)

        I would appreciate knowing the limitations the iPad Swift Playgrounds app imposes. For example I was surprised to find that I got a runtime error when I tried to create more than five sub views. Playing with UILabels to present a form is very limiting!

         

        This is the code I used:

         

        import UIKit

        import PlaygroundSupport

         

        class MyViewController : UIViewController {

            let square50 = CGSize(width: 50, height: 50)

            override func viewDidLoad() {

                var myFrame = CGRect(origin: .zero, size: square50)

                for index in 0...4 {

                    view.addSubview(UIView(frame: myFrame)) // fails at 6th!

                    (view.subviews[index] as! UIView).backgroundColor = .red

                    myFrame.origin.y += 80

                }

            }

        }

        PlaygroundPage.current.liveView = MyViewController()

        • Re: Coding on ipad
          adlibber Level 1 Level 1 (0 points)

          In reply to my own question! This code runs fine under XCode on my iMac. The problem rests with the Swift Playgrounds app and is therefore a BUG in the Playgrounds app. Interesting it wasn't spotted by anyone (other than me).