Post

Replies

Boosts

Views

Activity

Which software should we use to run your app project?
Hi. Now I'm on submitting process. For submitting .zip section, there's Which software should we use to run your app project? with two options which is: Swift Playgrounds 4.0.2 on iPadOS 15.3 Xcode 13.2.1 on macOS 12.2.1 I developed my app on Xcode but target of my app is iPad Should I select Swift Playgrounds 4.0.2 on iPadOS 15.3 ? (I cannot run my app on my Mac because I'm using intel-Mac)
2
0
859
Apr ’22
Using Swift playground UIKit, Constraints are not working
I'm working on Swift Playground right now. I declared UI objects in loadView() Swift class ViewController: UIViewController {       override func loadView() {     let view = UIView(frame: viewRect)     view.backgroundColor = UIColor.white           let titleLabel = UILabel()     titleLabel.translatesAutoresizingMaskIntoConstraints = false     titleLabel.text = "title"     titleLabel.backgroundColor = .gray                 view.addSubview(titleLabel)     NSLayoutConstraint.activate([       titleLabel.widthAnchor.constraint(equalToConstant: 200),       titleLabel.topAnchor.constraint(equalTo: view.topAnchor, constant: 100),       titleLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor)     ])           let subLabel = UILabel()     subLabel.translatesAutoresizingMaskIntoConstraints = false     subLabel.text = "title"     subLabel.backgroundColor = .red                 view.addSubview(subLabel)     NSLayoutConstraint.activate([       subLabel.widthAnchor.constraint(equalToConstant: 100),       subLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 100),       subLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor)     ])           self.view = view   } } in this case, Everything works fine. But I tried to declare those labels outside of loadView() like this: Swift class ViewController: UIViewController {       var titleLabel = UILabel()   var subLabel = UILabel()       override func loadView() {     let view = UIView(frame: viewRect)     view.backgroundColor = UIColor.white     titleLabel = UILabel()     titleLabel.translatesAutoresizingMaskIntoConstraints = false     titleLabel.text = "title"     titleLabel.backgroundColor = .gray                 view.addSubview(titleLabel)     NSLayoutConstraint.activate([       titleLabel.widthAnchor.constraint(equalToConstant: 200),       titleLabel.topAnchor.constraint(equalTo: view.topAnchor, constant: 100),       titleLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor)     ])                 subLabel.translatesAutoresizingMaskIntoConstraints = false     subLabel.text = "title"     subLabel.backgroundColor = .red                 view.addSubview(subLabel)     NSLayoutConstraint.activate([       subLabel.widthAnchor.constraint(equalToConstant: 100),       subLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 100),       subLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor)     ])           self.view = view   } } When I run this code (which labels are declared outside of loadView()), Constraints are not working except for width/height constraints. Also, when i run the code only with 1 label, Everything works fine even label is declared outside of loadView() Is there any solution to fix this problem?
1
0
1.4k
Apr ’21
Block rotation & fix landscape for .swiftpm
Greetings, I want to force my app's Orientation. Most solutions for "How to force orientation to Landscape for SwiftUI" seems works only for "real" SwiftUI project, not .swiftpm How can I force orientation to landscape for Swift Playground App Project?
Replies
2
Boosts
0
Views
4.4k
Activity
Apr ’22
Which software should we use to run your app project?
Hi. Now I'm on submitting process. For submitting .zip section, there's Which software should we use to run your app project? with two options which is: Swift Playgrounds 4.0.2 on iPadOS 15.3 Xcode 13.2.1 on macOS 12.2.1 I developed my app on Xcode but target of my app is iPad Should I select Swift Playgrounds 4.0.2 on iPadOS 15.3 ? (I cannot run my app on my Mac because I'm using intel-Mac)
Replies
2
Boosts
0
Views
859
Activity
Apr ’22
Block Rotation & force Landscape on .swiftpm
Greetings, I want to force my app's Orientation. Most solutions for "How to force orientation to Landscape for SwiftUI" seems works only for "real" SwiftUI project, not .swiftpm How can I force orientation to landscape for Swift Playground App Project?
Replies
1
Boosts
0
Views
1.2k
Activity
Apr ’22
Using Swift playground UIKit, Constraints are not working
I'm working on Swift Playground right now. I declared UI objects in loadView() Swift class ViewController: UIViewController {       override func loadView() {     let view = UIView(frame: viewRect)     view.backgroundColor = UIColor.white           let titleLabel = UILabel()     titleLabel.translatesAutoresizingMaskIntoConstraints = false     titleLabel.text = "title"     titleLabel.backgroundColor = .gray                 view.addSubview(titleLabel)     NSLayoutConstraint.activate([       titleLabel.widthAnchor.constraint(equalToConstant: 200),       titleLabel.topAnchor.constraint(equalTo: view.topAnchor, constant: 100),       titleLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor)     ])           let subLabel = UILabel()     subLabel.translatesAutoresizingMaskIntoConstraints = false     subLabel.text = "title"     subLabel.backgroundColor = .red                 view.addSubview(subLabel)     NSLayoutConstraint.activate([       subLabel.widthAnchor.constraint(equalToConstant: 100),       subLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 100),       subLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor)     ])           self.view = view   } } in this case, Everything works fine. But I tried to declare those labels outside of loadView() like this: Swift class ViewController: UIViewController {       var titleLabel = UILabel()   var subLabel = UILabel()       override func loadView() {     let view = UIView(frame: viewRect)     view.backgroundColor = UIColor.white     titleLabel = UILabel()     titleLabel.translatesAutoresizingMaskIntoConstraints = false     titleLabel.text = "title"     titleLabel.backgroundColor = .gray                 view.addSubview(titleLabel)     NSLayoutConstraint.activate([       titleLabel.widthAnchor.constraint(equalToConstant: 200),       titleLabel.topAnchor.constraint(equalTo: view.topAnchor, constant: 100),       titleLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor)     ])                 subLabel.translatesAutoresizingMaskIntoConstraints = false     subLabel.text = "title"     subLabel.backgroundColor = .red                 view.addSubview(subLabel)     NSLayoutConstraint.activate([       subLabel.widthAnchor.constraint(equalToConstant: 100),       subLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 100),       subLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor)     ])           self.view = view   } } When I run this code (which labels are declared outside of loadView()), Constraints are not working except for width/height constraints. Also, when i run the code only with 1 label, Everything works fine even label is declared outside of loadView() Is there any solution to fix this problem?
Replies
1
Boosts
0
Views
1.4k
Activity
Apr ’21