16,293 questions
0
votes
2
answers
287
views
iOS 26 Modal View Controller with Transparent Background
Prior to iOS 26, this successfully gave me a modal view with a transparent background:
let settingsVC = MySettingsViewController()
settingsVC.modalPresentationStyle = .automatic
self.present(...
0
votes
0
answers
626
views
Scroll edge appearance on UITabBar not working in attempt to replicate UITabBarController with custom view controller
Note: The following is a bit long but there's just no way to reduce the code any further and still demonstrate the issue.
For reasons I won't get into, I am creating my own implementation of ...
0
votes
1
answer
17
views
Does adding a bar button item to the navigation bar programmatically when offering scene support differ from the old app delegate approach
I have used the following code for years to add a right bar button item to the navigation bar, but for some unknown reason, this no longer works. It stopped working when I updated my app to have Scene ...
0
votes
1
answer
83
views
How to solve UIViewControllerRepresentable bug in Xcode?
I'm trying to create a UIViewControllerRepresentable struct, but Xcode keeps complaining about implementing stubs
struct PassVC: UIViewControllerRepresentable {
typealias UIViewControllerType = ...
0
votes
0
answers
98
views
Is SwiftUI's UIHostingController causing me high energy impact? How to prevent it?
I am using the FluidGradient SwiftUI library for an animated gradient background in my app. It works fine.
However, my app is in Swift and so I am using UIHostingController to display the ...
2
votes
1
answer
457
views
How to communicate from an iOS ViewController to a Kotlin Composable
I'm playing with KMM and I'm trying to achieve a solution where my Jetpack Composables are used only 100% just for the UI.
I mean that I want to use KMM strictly to only create UI, I don't want to ...
1
vote
1
answer
75
views
Get reference to View ControllerA from ViewControllerB to change property [closed]
I have a custom ViewController A with an instance variable or property that I want to change from a second custom view controller launched by a navigation controller for ViewControllerA.
Here is my ...
0
votes
2
answers
115
views
Singleton for UIViewControler in Swift disallowed by compiler?
I have a UIViewController class with a variable shared that allows other classes to reach it as a singleton. However, the compiler (with Main Thread Checker enabled in Scheme Settings) is flagging the ...
1
vote
1
answer
37
views
View Controller has different dimensions in simulator and device
I have a board game app designed for iPad. At the start of each turn, if conditions are right, a user can display a popup showing a crossword-style grid. The popup is designed as a freeform XIB. I ...
0
votes
0
answers
48
views
How to re-trigger randomElement() each time the user navigates back to the viewController [duplicate]
I am very, very new to Swift/iOS so I apologize if this is a simple question or I am misusing terminology.
I am working on an app and there is a specific viewController that includes a randomly ...
0
votes
0
answers
54
views
Google IMA SDK: UIViewControllerHierarchyInconsistency - IMAAdViewController parent is null instead of NativeVideoPlayerViewController
I'm developing an app with a YouTube-like PipView (Picture-in-Picture) structure for live broadcasting. The app crashes during the transition from the live broadcast tab to PipView, following these ...
1
vote
1
answer
137
views
How to set initial background color of Mac Catalyst windows?
My iOS and Mac Catalyst app uses a dark color theme by default, regardless of the system color theme. When the app presents a modal view controller (a popup or a popover) on iOS, the background of ...
1
vote
1
answer
253
views
Dynamically resize SwiftUI UIViewRepresentable with intrinsic content size / sizeThatFits
I have an ExpandingView like this:
struct ExpandingView: View {
@State var isExpanded = false
var body: some View {
RoundedRectangle(cornerRadius: 16.0)
.fill(Color....
0
votes
0
answers
26
views
MacCatalyst Scene Frame needs adjustment
I don't know why, but for my MacCatalyst target, I have to make my view controller Y orgin 36 and the subtract the view height by 36 points, or the view is clipped.
The following works in my main ...
0
votes
0
answers
77
views
Presenting a rotating, sheet-style modal on top of another view controller locked in portrait orientation
I have an app whose main view controller (call it VC-A) is locked in portrait orientation. I would like to present a sheet-style modal (call it VC-B) over top of it, allowing the modal to rotate ...
0
votes
0
answers
48
views
Error occurs when I use IBOutlet for connection to custom component in iOS 12.5.7
Error occurs when I use IBOutlet for connection to DefaultTextField in iOS 12.5.7. But if I use programmatic application, no error occurs.
This error usually occurs iPhone 6 and iPhone 6 Plus in iOS ...
0
votes
0
answers
100
views
How to handle the conflicting orientation masks between UIViewController and AppDelegate
I noticed that the Apple official documentation for UIViewController describes handling view rotation as follows:
The intersection of the app’s orientation mask and the view controller’s orientation ...
0
votes
1
answer
120
views
UIKit - UISheetPresentationController embedded in the page
I am working on an iOS project using UIKit, and I am implementing a UISheetPresentationController. My goal is to keep the sheet fixed on the current page. However, when I navigate to a new page (e.g., ...
5
votes
1
answer
610
views
How to make bigger sized presented view same as like earlier version in iOS 18 - Swift
I'm facing an issue in presenting UIViewController in iOS 18.
For the earlier version presentation looks good.
I need a same height and width in every version.
Any quick solution is appreciated. Thank ...
1
vote
0
answers
41
views
UIViewRepresentable TextField that can append a uneditable string and follows other rules
In Swift UI I am struggling to find a solution to editing Int16 and Double values primarily linked to CoreData entities.
The SwiftUI TextField("key", value: $int16, format: .number) crashes ...
-1
votes
1
answer
85
views
Why doesn't my UILabel update its text properly?/Why does my UILabel show the wrong text?
I have two labels, which I will refer to as labelA and labelB. I also have some buttons that trigger some code. Here is one.
@IBAction func buttonA1(_ sender: UIButton) {
if game1 == true &...
0
votes
0
answers
63
views
How I can override portrait orientation lock mode in swift?
I am developing a camera app in Swift and I want it to rotate according to the device orientation, even when the portrait orientation lock mode is turned on via the control center. I noticed that the ...
0
votes
1
answer
141
views
UIViewController inside multiple coordinators in "Coordinator" pattern in Swift?
I've read about Coordinator pattern and in all cases it is described as below:
class SomeViewController: UIViewController {
weak var coordinator: CoordinatorProtocol?
}
protocol ...
0
votes
1
answer
122
views
Share Audio (MP3) to WhatsApp with text using UIActivityViewController
I'm trying to share an audio file (MP3) using UIActivityViewController. While the audio file is shared successfully, the accompanying text message I'm adding does not appear in the message. It only ...
-2
votes
1
answer
64
views
Saving edited PDFs directly to application from QuickLook [closed]
I'm stuck on a problem where I need to be able to have the same editing capabilities as in .quickLookPreview and be able to save the edited file to the application with the "Done" button.
So,...
0
votes
1
answer
180
views
No ObservableObject of type found. A View.environmentObject(_:) for "ClassName" may be missing
ToggleView is unable to access the manager class environment object
I have fully identified the cause of the crash to be because of my attempt in trying to access an environment object when presenting ...
0
votes
1
answer
51
views
Synchronisation of pushing and presenting view controllers
My app has a scenario where one module shows a view controller, and a second module tries to push another. Those modules are separated pieces of software (a framework and the app).
The problem is if ...
1
vote
0
answers
103
views
SwiftUI Sheet embedded in a ViewController does not slide away with VC in iOS16
In iOS17, I have the expected result:
When popping the ViewController (SecondVC), the sheet goes away together with it.
In iOS 16 however, the sheet stays in place and dismisses after the VC dismiss ...
-2
votes
1
answer
134
views
How to dismiss a specific UIViewController on the backstack without dismissing other UIViewControllers? (UIKit) [closed]
I have several UIViewControllers that I present programmatically with modalPresentationStyle = .fullScreen. My stack of UIViewControllers looks like this:
ViewControllerA -> ViewControllerB -> ...
0
votes
0
answers
91
views
How to Get the Top-Most View Controller in iPad with Multiple Scenes (UIScene) in Swift?
I have an existing method to get the top-most view controller in iOS applications without multiple scenes, which works perfectly for single window applications on both iPhone and iPad:
extension ...
0
votes
0
answers
38
views
Updating a MKMapView based on transitions between UIViewControllers
I am building a map application similar to Apple Maps. Basically a half height sheet over a full screen map.
How shall I structure and detect transitions between view controllers on the sheet to ...
0
votes
1
answer
72
views
Application forgets current View Controller and tableview after alert controller tapped in Swift
I am running into issues where my app seems to forget the current View Controller and its properties--namely a tableView--after launching an AlertController with Action methods.
For example, after ...
-1
votes
1
answer
106
views
UIViewController.presentModalViewController hangs indefinitely
I have 3 view controllers, VC1, VC2, and VC3, that are instantiated when the app starts.
I want to present them modally in a loop, like this:
VC1 -> VC2 -> VC3 -> VC1
On each view controller,...
0
votes
1
answer
132
views
Non-Storyboard / Programmatically-Generated UIViewControllers
I have been researching how to add some special effects (fireworks) to my app, and doing so appears to require the programmatic generation of UIViews and UIViewControllers, as well as no longer being ...
0
votes
0
answers
59
views
Detect when a UIViewController gets dismissed by swiping down before the dismissal animation ends
With reference to this answer, the "endAppearanceTransition()" is called on the completion of the dismissal animation, about a second after the view disappears. I need to perform a specific ...
1
vote
1
answer
200
views
React Native iOS modal/popup disappears immediately
I am developing a native module to integrate payments.
After debugging with xcode and using symbolic breakpoints I found the source of the issue, but I want to understand why this is happening, and ...
0
votes
1
answer
81
views
What is the correct approach of Unit Testing in iOS?
class RemoveMyDataConsentFormVCTests: XCTestCase {
var viewController: RemoveMyDataConsentFormVC!
override func setUp() {
super.setUp()
let storyboard = UIStoryboard(...
-1
votes
1
answer
139
views
Setup the constrains between the UIView and UIViewController
I want to add view controller as subview inside the UIView . I have given the required constrains but I am not figure it out why it overlapping . Here is minimal code for it. I have given the top , ...
0
votes
0
answers
56
views
Children view controllers must have a common parent view controller in swift
I have created one container view . Here I'm adding two view controller content into single view controller. I am rendering the view based on the different state but I want to combine both view ...
0
votes
2
answers
127
views
Adding two UIView vertically
I have two UIView and I want to add detailsView as subview with other view. I am getting following error:
Cannot convert value of type 'MovieDetailsDisplayViewController.detailsView.Type' to expected ...
0
votes
0
answers
60
views
UICollection view is not rendering properly
I am navigating to collection view when I select didSelectRowAt at table view. I am expecting to show collection view with configuration. But is not showing..
Here is the code for
extension ...
-1
votes
1
answer
81
views
How to delete UINavigationController's space programmatically using Swift?
When I redirect to a page from UINavigationController, the destination page shows the contents of the Navigation Bar with more space above than expected. How can I fix this situation?
...
0
votes
1
answer
34
views
someone help or explain why the view looks like this and it doesnt take me to the new view controller
this is the initial view when i click the button it will bring up the next view
this view should be the entire screen legth i dont know whats its doing or what this is called to beable to fix this
...
0
votes
1
answer
84
views
UINavigationController glitchy animation when pushing new view controller
I want both the welcome view controller and ViewController2 to have a UIVisualEffectView for their background. When I push ViewController2, the animation is very glitchy and doesn't fully animate to ...
0
votes
1
answer
404
views
How To: Simple UIViewController w/ .xib using XCode15
I'm having issues creating a simple UIViewController in XCode15.
I want to create a .xib and accompanying .swift file as a controller.
Things seemed to have changed and I can't create a ...
0
votes
1
answer
123
views
How to fade up initial root view controller to reveal new background root view controller
I have 2 root view controllers that I need to animate (slide up/fade) between.
When I press a button on viewControllerA, viewControllerB should load itself in the background and set itself as the root ...
0
votes
2
answers
68
views
Delegate returning nil even though delegate has been set
new to stackoverflow so please let me know if extra context needs to be provided but I have an xcode project (fitness app) and in it I have a tab bar controller , two view controllers called ...
0
votes
1
answer
177
views
Can't make changes in View from Controller
I'm trying to create my first MVC project, which will check code phrase and open access to user. I've created 3 files:
Model - checks if the code phrase is correct and returns a result that is used ...
0
votes
1
answer
333
views
How can I use the UIViewController in Swiftui (Store Kit - LoadProduct)?
I would like to open the app store with my app inside my swiftui app, e.g with sheet.
I found this article
Link:
Here are my code for SKStoreProductWithClosure.swift class.
import StoreKit
class ...
2
votes
0
answers
93
views
XCode 15 view controller glitched when presented first time after installing bulid on device
Today I have faced the problem after bulding app on device, modal presented view controller glitched. Intresting that it throws only ONE TIME after app builded on device and then it's work correct ...