Post

Replies

Boosts

Views

Activity

Should I Leave 4.2 Migration Helper Functions in Place?
...or modify my program. I migrated a Swift 3 program to Swift 4.2 and several helper functions were added to some of the files. It is tempting to modify the old code to incorporate what the helper functions do and then delete the helper functions, but it seems like a lot of work. I haven't noticed any performance hits with the helper functions and I intend to update to Swift 5 anyway, but I'm wondering what others think. Thank you.
1
0
463
Jul ’21
UIScreen.main.bounds Returning Wrong Value During iPhone Simulation
Hi. I have a short program that adds two buttons in a single view and prints the screen bounds, but those bounds aren't right with iPhone 7Plus simulator after rotating device so the two button subviews aren't placed correctly. This issue does not seem to happen when using iPad simulators. I know I can just simply use the size input from viewWillTransition() function but that doesn't tell me why it isn't showing the correct screen bounds rectangle coordinates on just the iPhone simulator. For some reason it thinks device is in whatever mode it was in when I start up the app and rotate it. Like after I start up in Portrait and change to Landscape the code still prints "Device is in portrait mode" and prints the bounds as being in Landscape mode. I am using XCode 13.2.1 and iOS 15.2 for testing. All possible device orientations are in the info.plist for both iPhone and IPad. Here is the code I am testing with: import UIKit class TestViewController: UIViewController {          lazy var pickButton : UIButton = {         let button = UIButton(frame: CGRect(x: 0,                                             y: 0,                                             width: 100,                                             height: 100))         button.setTitle("Pick", for: .normal)         button.setTitleColor(.black, for: .normal)         //button.addTarget(self, action: #selector(showPicker), for: .touchUpInside)         return button     }()          lazy var resultsButton : UIButton = {         let button = UIButton(frame: CGRect(x: 0,                                             y: UIScreen.main.bounds.height - 100,                                             width: UIScreen.main.bounds.width,                                             height: 100))         button.setTitle("Show selected", for: .normal)         button.setTitleColor(.black, for: .normal)         //button.addTarget(self, action: #selector(showResults), for: .touchUpInside)         return button     }()     override func viewDidLoad() {         super.viewDidLoad()                  determineMyDeviceOrientation()                  /*let device = UIDevice.current         device.beginGeneratingDeviceOrientationNotifications()         let notificationCenter = NotificationCenter.default         notificationCenter.addObserver(self, selector: #selector(deviceOrientationChanged),             name: Notification.Name("UIDeviceOrientationDidChangeNotification"),             object: nil)*/                                    view.addSubview(resultsButton)         view.addSubview(pickButton)         pickButton.center = view.center     }          override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {                  print ("size \(size)")         print (UIScreen.main.bounds)                  determineMyDeviceOrientation()                  pickButton.center = CGPoint(x: UIScreen.main.bounds.width/2, y: UIScreen.main.bounds.height/2)         resultsButton.frame = CGRect(x: 0, y: UIScreen.main.bounds.height - 100, width: UIScreen.main.bounds.width, height: 100)                  //pickButton.center = CGPoint(x: size.width/2, y: size.height/2)         //resultsButton.frame = CGRect(x: 0, y: size.height - 100, width: size.width, height: 100)     }          func determineMyDeviceOrientation() {                      let i = UIApplication.shared.windows.first!.windowScene!.interfaceOrientation.isLandscape           print (i)                      if i {               print("Device is in landscape mode")           } else {               print("Device is in portrait mode")           }       }     @objc func deviceOrientationChanged() {         print("Orientation changed")         inspectDeviceOrientation()     }     func inspectDeviceOrientation() {         let orientation = UIDevice.current.orientation         switch UIDevice.current.orientation {         case .portrait:             print("portrait")         case .landscapeLeft:             print("landscapeLeft")         case .landscapeRight:             print("landscapeRight")         case .portraitUpsideDown:             print("portraitUpsideDown")         case .faceUp:             print("faceUp")         case .faceDown:             print("faceDown")         default: // .unknown             print("unknown")         }         if orientation.isPortrait { print("isPortrait") }         if orientation.isLandscape { print("isLandscape") }         if orientation.isFlat { print("isFlat") }     } }
1
0
2.4k
Feb ’22
Apple's Mac Catalyst Tutorial iPhone "Plus" Size SplitViewController Issues
I'm new to using a SpliViewController in iOS and wanted to learn to use it since it is a part of an Apple tutorial for Mac Catalyst. The first tutorial is here: https://developer.apple.com/tutorials/mac-catalyst/turning-on-mac-catalyst. It works fine on out of the box as it should for "non-plus" size iPhone simulators in both portrait and landscape. On "Plus" size phones it switches to a SVC in landscape, which causes lots of problems in some situations when switching from portrait to landscape and vice versa. This is the screen when first loading in portrait on iPhone 7 Plus: This what it looks like when a recipe is selected and shown in portrait then rotated to landscape Notice the recipe detail is where the recipe list should be and the detail should be on the right: When you tap the back button the recipe list is shown. Notice the scrunched-up text. Tapping the expand button expands the detail view and it looks ok. Also notice how the tab bar items are spaced and barely fit the alloted space: If you rotate back to portait and select a diiferent recipe, then rotate to landscape you get this: This is just from running the app on iPhone the way it is programmed by Apple without any alterations. I have completed the tutorial up to " Supporting the Touchbar" but of course the behavior has not changed for plus-sized iPhones. This is a "Classic" SVC since it runs in iOS 13.4 I have tried messing with the SplitViewDelegate because that seems to be where I should be looking, but not getting anywhere even after spending a lot of time looking around the net. I'm hoping someone can look at the project and tell me what can be done to fix it. I know the tutorial is aimed at porting an iOS program to Mac but I do think it should run on iOS properly since that is where the porting starts. Thank you.
0
0
435
Mar ’22
Toobar Items Not Clickable Mac Catalyst Tutorial
Hi, I am giving Mac Catalyst a try and Apple has provided a tutorial for that but it seems a bit buggy. In the tutorial https://developer.apple.com/tutorials/mac-catalyst/updating-the-app-icon there is the completed Catalyst xcode project (in the Complete folder). I downloaded and ran the completed project in Xcode Version 14.2, using my Mac to run it in simulation. The toolbar at the top of the window has the icons for edit and favorite but they appear to be greyed out and don't do anything when clicked. The selectors are set properly for their actions in the ToolBarDelegate file but nothing happens when I select a recipe, which it appears you have to do in order for those buttons to work, then try to click either one of those items Those buttons never appear to be enabled at all even though I have selected a recipe and the coding seems correct. I am confused as to why this doesn't work. The NSSharingServicePickerToolbarItem is enabled and seems to work. I didn't post any code since the project can be readily downloaded and viewed/run. Any help is much appreciated
1
0
796
Apr ’23
Mac Catalyst and NSToolbar
I have submitted FB12157356 for an issue where Mac Catalyst does not play nicely with NSToolBar. Supposedly clickable items in the toolbar do not enable when they should. This is from the Mac Catalyst tutorial at https://developer.apple.com/tutorials/mac-catalyst/updating-the-app-icon Here is what I wrote: In the tutorial https://developer.apple.com/tutorials/mac-catalyst/updating-the-app-icon there is the completed Catalyst xcode project (in the Complete folder). I downloaded and ran the completed project in Xcode Version 14.2, using my Mac OS 12.6.5 to run it. The NSToolBar at the top of the window has the toolbar items for edit and favorite, but they remain greyed out and don't do anything when a recipe is selected. The selectors seem to be set properly for their actions in the ToolBarDelegate file but nothing happens when I select a recipe and the DetailViewController displays the recipe, which it appears you have to do in order for those toolbar items to work. Those buttons never appear to be enabled at all even though I have selected a recipe and the sample coding seems correct. Steps to Reproduce: Download and open the Xcode project in the "Complete" folder from the link provided above. Run the project with Mac as the the simulator target. Select a recipe The toolbar edit icon should be enabled and should display the RecipeEditorViewController when clicked. The favorite (heart) icon should be filled if the recipe is a favorite, and allow you to favorite a recipe if it isn't already a favorite. Interestingly, if you enable the Touch Bar when running the app from Xcode, the Touch Bar displays the edit and favorite icons correctly and the react properly to touches. If anyone has time to look at the tutorial and any suggestion for a workaround so that the toolbar items work correctly I'd love to hear it. Catalyst has lots of potential but this apparent bug isn't helping.
1
1
799
May ’23
[WindowHosting] UIScene property of UINSSceneViewController was accessed before it was set. What does this mean?
Getting this error several times when presenting a modal window over my splitview window when running it on my Mac using Swift/Mac Catalyst in XCode 14.2. When I click the Cancel button in the window then I get Scene destruction request failed with error: (null) right after an unwind segue. 2023-07-04 16:50:45.488538-0500 Recipes[27836:1295134] [WindowHosting] UIScene property of UINSSceneViewController was accessed before it was set. 2023-07-04 16:50:45.488972-0500 Recipes[27836:1295134] [WindowHosting] UIScene property of UINSSceneViewController was accessed before it was set. 2023-07-04 16:50:45.496702-0500 Recipes[27836:1295134] [WindowHosting] UIScene property of UINSSceneViewController was accessed before it was set. 2023-07-04 16:50:45.496800-0500 Recipes[27836:1295134] [WindowHosting] UIScene property of UINSSceneViewController was accessed before it was set. 2023-07-04 16:50:45.994147-0500 Recipes[27836:1295134] Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x7f7fdf068a00>. bleep 2023-07-04 16:51:00.655233-0500 Recipes[27836:1297298] Scene destruction request failed with error: (null) I don't quite understand what all all this means. (The "bleep" was a debugging print code I put in the unwind segue). I'm working through Apple's Mac Catalyst tutorial but it seems to be riddled with bugs and coding issues, even in the final part of the completed app which I dowmloaded and ran. I don't see these problems on IPad simulator. I don't know if it's because Catalyst has problems itself or there's something else going on that I can fix myself. Any insight into these errors would be very much appreciated! PS: The app seems to run ok on Mac without crashing despite the muliple issues
4
3
1.4k
Jul ’23
.allowsEditing and Mac Catalyst App
Hi, I have an imagePickerController where .allowsEditing is set to true after picking an image. I can move/scale it in iPhone/iPad simulators, but running on my Mac the scaling part of it doesn't work and I don't know how I could go about making the scaling work. Any suggestions much appreciated. Update: I am using a Magic Mouse. No Trackpad or Touchscreeen Mac.
0
0
370
Mar ’24