uiviewcontroller

How to check that user is back from Settings

不打扰是莪最后的温柔 提交于 2020-08-08 06:21:40
问题 I am sending local notifications to my users, and I want to show the relevant title on the notification settings button. If local notifications are off, this title should be "Notifications: off", and if local notifications are on, this title should be something like "Preferences". Right now I'm checking this in viewDidLoad and viewDidAppear, and it works. if UIApplication.sharedApplication().currentUserNotificationSettings()?.types.rawValue == 0 { //the first title } else { //the second title

iOS 13's presentationControllerDidDismiss() Not Called for Popover in Compact Environment

本小妞迷上赌 提交于 2020-06-16 02:19:07
问题 I am updating my app for iOS 13’s new “card-style” modal views. All has been working well using UIAdaptivePresentationControllerDelegate ’s presentationControllerDidAttemptToDismiss() and presentationControllerDidDismiss() functions. But, for views that have their .modalPresentationStyle set to .popover , presentationControllerDidDismiss() is not called when being presented in compact environments (such as a phone or iPad in split or slide-over). It’s called correctly when presented in a

IOS | Unable to change root view controller in app delegate

元气小坏坏 提交于 2020-06-06 08:24:22
问题 I am building an app whose root view controller must be changed if the user is logged in. Say if the user is logged in I must show a tab bar controller as the home screen if the user is not logged in, I must show an Authentication controller. Both my controllers are storyboard controllers. Now in my app delegate, I have put the following code window = UIWindow(frame: UIScreen.main.bounds) if UserDefaults.standard.bool(forKey: Constants.UserDefaultsKeys.isLoggedIn){ initialViewController =

Issues with SKScene on iPad simulator not filling screen in Xcode 11 beta 7

大兔子大兔子 提交于 2020-05-30 07:05:44
问题 In Xcode 11 beta 7, I am having issues with my SKScene , my GameScene does not fill the entire screen of the iPad simulator. This is true for all iPad simulators. On my physical iPad the Game Scene is as intended, but I worry this may not be true of all iPad's. On all iPhone simulators and on my iPhone, the Game Scene is also displayed as intended. I have two SKScenes , one is the Main Menu screen which fills the entire screen, but my Game Scene does not, when I load the Game Scene it is

Updating an @EnvironmentObject var to pass data to PageViewController in SwiftUI results in loss of swiping between ViewControllers

情到浓时终转凉″ 提交于 2020-05-29 09:23:02
问题 In my SwiftUI app, I currently have a PageViewController implemented using UIKit. It follows the traditional SwiftUI - UIKit implementation outlined in Apple's SwiftUI UIKit integration tutorials. I have the data that populates a UIViewController, within the controllers array that is passed to the PageViewController, provided by an @Environment variable. In a different screen in the app, you can issue an action that causes the Environment object to update, triggering a re-render of a

Updating an @EnvironmentObject var to pass data to PageViewController in SwiftUI results in loss of swiping between ViewControllers

两盒软妹~` 提交于 2020-05-29 09:21:09
问题 In my SwiftUI app, I currently have a PageViewController implemented using UIKit. It follows the traditional SwiftUI - UIKit implementation outlined in Apple's SwiftUI UIKit integration tutorials. I have the data that populates a UIViewController, within the controllers array that is passed to the PageViewController, provided by an @Environment variable. In a different screen in the app, you can issue an action that causes the Environment object to update, triggering a re-render of a

Bi-Directional communication between ViewController and AppDelegate with swift 2 for iOS

ⅰ亾dé卋堺 提交于 2020-04-30 07:45:10
问题 I am developing an iPhone app that uses the PubNub network to publish data to a Raspberry Pi and subscribe to messages from it. Xcode 7, Swift 2. These messages are sent using an object that I call client, which is declared in the AppDelegate.swift init() method. I have been able to successfully reference my AppDelegate from my one and only ViewController, however getting data back to my ViewController from the AppDelegate is where things have gotten tricky for me. I'm aware that this bi

Where should I set UINavigationController's delegate property?

三世轮回 提交于 2020-04-11 12:08:29
问题 I'm working with some custom controller transitions, which make use of UINavigationController's delegate property. If I set it in viewDidLoad() , self.navigationController?.delegate gets deallocated at some point after the push. Setting it in viewWillAppear() works, but I'm wondering why that property gets deallocated in the first place, and where people typically set this property. // The first time you push, it will work correctly, and the delegate function below is called. After you pop

How to refresh UIViewController programmatically?

冷暖自知 提交于 2020-03-15 06:05:09
问题 I have a ViewController in which the user selects a card (a custom UIButton) out of a UIScrollView. I have intercepted the touch event selecting the card and identified it, and then removed it from the data source, but it still exists in the UISubView. How do I get rid of it? Refreshing the view should show it removed from the view. How do I do that? 回答1: you can do it in one of two places: in your viewcontroller directly in the view you need to call the function setNeedsDisplay if you do it

How to refresh UIViewController programmatically?

浪尽此生 提交于 2020-03-15 06:03:44
问题 I have a ViewController in which the user selects a card (a custom UIButton) out of a UIScrollView. I have intercepted the touch event selecting the card and identified it, and then removed it from the data source, but it still exists in the UISubView. How do I get rid of it? Refreshing the view should show it removed from the view. How do I do that? 回答1: you can do it in one of two places: in your viewcontroller directly in the view you need to call the function setNeedsDisplay if you do it