I started a new project in SwiftUI from Xcode's Template and run the app. When debugging the View Hierarchy I can see that the app creates a UIHostingController to wrap the SwiftUI's view.
Has this always been the case or this is an update in some iOS/Xcode version. Is there any version of the SDK that SwiftUI is running without the UIHostingController?
My project will use UIApplication.Window to get the top most UIController to show a SDK's SFAuthenticationViewController which takes a presented UIController as a parameter. Ensuring that the default UIHostingController exists in all versions (>=iOS 15) of the app is the priority concern.
If Apple changed how SwiftUI behaves since its launch (from no UIHostingController to with `UIHostingController) then they might switch it again, so I will go with an alternative approach.
I tried starting a new project on Xcode 14.0 and Xcode 14.2 with iOS 15.0 and iOS 16.2. All showing the default UIHostingController.
Related
I have noticed a bug introduced when building with Xcode 14.
The navigation bar of my swiftui view is whited out and does not properly display the title, back button or other navigation items.
I haven't found anyone else reporting this issue online but it is clearly a change in how Xcode builds the app.
I have verified that building with Xcode 13.4.1 produces the expected navigation bar.
I manually downloaded 13.4.1 in order to continue deploying builds without this bug but I know eventually I will have to investigate why Xcode 14 is causing this issue. I'm hoping there is a fix that Apple discovers and releases to fix this issue.
The navigation bar is programmatically set through a view controller using a UIHostingController as its rootView.
I have found that this only happens when injecting swiftui into a UIKit app using UIHostingController. The SwiftUI view does not use a NavigationView so there shouldn't be any overlap between what is displayed in the navigation bar from the viewController and what is displayed from the SwiftUI view.
I never heard back from Apple but I figured out the issue!
In my case the app had a few settings that worked in Xcode 13 but created the issue in Xcode 14.
I had to remove this key/val from the Info.plist for my app
UIStatusBarStyle
UIStatusBarStyleDarkContent
I removed a setting that was set in AppDelegate
application.setStatusBarStyle(UIStatusBarStyleLightContent)
I explicitly called this in every ViewController (I used a base class that all my View Controllers inherit)
navigationController.setNavigationBarHidden(false, animated:false)
After the above changes the navigation bar showed up correctly and the top status bar also displayed correctly.
I am following the Udemy Advanced iOS and Firebase tutorial. His tutorial is on ios 8 and I am on 10, plus I am on Xcode 11.3 and he is on 9 I think.
Anyway, I followed the tutorial and when I launch it I get an error about LaunchScreen cannot use custom classes. So I unchecked use as Launch Screen. This now allows the simulator to run, but when it does I don't see the app I have built. All is show is a white screen with "Hello World" on it?
For some reason when I created a Single View app in Xcode it only created a LaunchScreen.storyboard so that is where I built my UI. I have noticed other tutorials Xcode automatically creates the Luanch storyboard and the Main storyboard?
The reason why you see the "Hello, World!" is you have created a SwiftUI app
For Xcode 11
When creating a new Xcode project and the user interface option is selected as SwiftUI as shown below
Then the initial project files will only contain the LaunchScreen.storyboard and the other files listed below. To configure the UI one needs to write SwiftUI code in the ContentView.swift
When creating a new Xcode project and the user interface option is selected as Storyboard as shown below
Then the initial project files will contain the LaunchScreen.storyboard and the Main.storyboard as shown below.
The fact is that I have a View Controller in my storyboard that is using StackViews. Now, I'm trying to make the application iOS 7 compatible but I don't want to remove that view controller. Is there a way to compile the project without that view controller? I tried to keep the build target of the storyboard to 9 but i would prefer if there is a way to hide that view controller at build time working with iOS 7 on the storyboard
Stack View came with iOS9 and you can't tell the Stack View to disappear depending on the running iOS. It's not possible to build the Storyboard depending on the iOS either. But it seems to be possible to select different storyboards depending on the used iOS. See this link. The cody is ojective-c, but it seems not that hard to transfer the logic.
You can either remove the Stack View or, what I'd suggest, build your App for iOS9, since some survey I've recently read, tells that up to 90% of all Apple Users upgrade to the newest iOS within a week. Your 3rd possibility is to build different storyboards depending on the iOS.
Edit: You may want to check out the OAStackView. Which implements most of the features from UIStackView and supports iOS 7+.
I am trying to modify my existing app to use a split view controller. I've followed the sample master/detail project structure by adding a split view controller into my storyboard, made it the initial view controller and everything seemed to be working fine, until I tried to run the app in an iOS 7 simulator. All of a sudden when I hit my breakpoint in application: didFinishLaunchingWithOptions self.window.rootViewController is now the type of my master view controller, not the split view controller itself.
I thought maybe then I just need to get the split view controller off of the root view itself and tried rootViewController.splitViewController but that is nil. I must have missed some set up step in enabling this split view controller, but I have no idea what it was.
It is because UISplitViewController isn't supported in iPhone in iOS7, only in iPad.
If you run your code in iPad iOS7 you will see your UISplitViewController.
Only in iOS8 Apple added support for iPhone as well.
So this ended up being a pretty obscure issue. It seemed to be caused by the way that the iOS 8 SDK and Xcode 6 handle storyboards and size classes. I intend to file a bug report with apple but the repro steps to get this to present are simple:
Create a new master/detail application
Set deployment target to below 8.0 (7/7.1 works)
Change application type from "Universal" to "iPad"
You have to comment out this line from the generated app delegate, it will crash in an iOS 7 target:
navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem;
Run on iPad simulator for iOS 7.1
The fix to this issue is to disable size classes on the storyboard. I theorize that the way that Xcode 6 and the iOS 8 SDK are handling size classes for iPad versus universal app builds causes this to not work on iOS 7 targets, but turning off size classes fixes the issue.
Are there any known issues with UISplitViewController in MonoTouch? I am using MonoDevelop 2.8.8.4, MonoTouch 5.2.10 and xCode 4.3.2 (4E2002)
I have a UISplitViewController. When I go to portrait I display a button which the user can click to view the 'master' view in a popup controller. On the simulator it works exactly as expected - the master is displayed in a popupviewcontroller.
However, on the device (running iOS5.1), the master view will get pushed in from the side (like it would on a UINavigationController.PushController()
and this from iOS 5.1 Release Notes:
In 5.1 the UISplitViewController class adopts the sliding presentation
style when presenting the left view (previously only seen in Mail).
This style is used when presentation is initiated either by the
existing bar button item provided by the delegate methods or by a
swipe gesture within the right view. No additional API adoption is
required to obtain this behavior, and all existing API, including that
of the UIPopoverController instance provided by the delegate, will
continue to work as before. If the gesture cannot be supported in your
app, set the presentsWithGesture property of your split view
controller to NO to disable the gesture. However, disabling the
gesture is discouraged because its use preserves a consistent user
experience across all applications.
Are there any known issues with UISplitViewController in Monotouch?
Nothing specific to MonoTouch and UISplitViewController - but like you found out the later has changed quite a bit internally for iOS 5.1 and this can show up in applications.
I am using MonoDevelop 2.8.8.4, Monotouch 5.2.10 and xCode 4.3.2 (4E2002)
What's even more important is which version of the iOS simulator are you using ? i.e. iOS 5.0 or iOS 5.1 ?
In any case be aware that different version of iOS calls their selectors at different times. This can lead to cases where the same code will behave differently on different iOS versions.
One known case for this is about UISplitViewController. You can read about it (why and how it can occurs) and how to fix this properly to work identically across both versions of iOS.
Disclaimer: link to my own blog
Yes this is the "new Feature".
There is no Popover(UISplitViewController MasterView) anymore.
I tried to change but nothing works. I asked the Monotouch Support for help. But the also dont know anything.
Here is a Link to my Question maybe this can answer your question better;)
UISplitViewController problems with IOS 5.1