Questions tagged [appdelegate]

In iOS, the app delegate is responsible for managing the app throughout its lifecycle by responding to events such as launch and termination.

1900 questions
250
votes
13 answers

iOS - Calling App Delegate method from ViewController

What I am trying to do is click a button (that was created in code) and have it call up a different view controller then have it run a function in the new view controller. I know it could be done relatively easily in IB but that isn't an option. An…
Mytheral
  • 3,865
  • 7
  • 32
  • 56
90
votes
15 answers

Get device token for push notification

I am working on push notifications. I wrote the following code for fetching a device token. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization…
85
votes
11 answers

UIStatusBarStyle not working in Swift

I'm trying to change the Status Bar color in my Swift app to white, but am hitting a brick wall. I have 3 ViewControllers that are each embedded in a NavigationController (could that be the issue? I've already tried to place the code in the…
davidrayowens
  • 1,502
  • 1
  • 13
  • 23
74
votes
10 answers

Opening view controller from app delegate using swift

I am trying to create a push notification which determines which view to open according to information obtained from the push. I have managed to get the information from the push, but I am now struggling to get the view to open Looking at other…
Lister
  • 1,038
  • 1
  • 9
  • 18
54
votes
20 answers

NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle

In my AppDelegate there is a problem I do not understand. RootViewController initially called ViewController and I changed it name. The application is formed by many ViewController then I have introduced a UINavigationController. Why this error…
Adriana Carelli
  • 4,276
  • 11
  • 41
  • 70
51
votes
14 answers

iOS 13: Swift - 'Set application root view controller programmatically' does not work

I have following code in my AppDelegate.swift to setup root view controller for an iOS application. But it does not work. It follows Target structure (defined under General tab) and ignores this code. (Xcode 11, Swift 5.1, iOS 13) class AppDelegate:…
Krunal
  • 68,602
  • 40
  • 230
  • 241
41
votes
6 answers

AppDelegate, rootViewController and presentViewController

I'm doing the Facebook integration tutorial, I want to show my MainViewViewController if the user has a valid token for the current state otherwise I want to show LoginViewController. MainViewAppDelegate.m - (BOOL)application:(UIApplication…
Boris-V
  • 437
  • 1
  • 4
  • 15
35
votes
7 answers

Present UIAlertController from AppDelegate

I'm trying to present a UIAlertController from the AppDelegate in my iOS app. Below is the alert and the present method. UIAlertController *alert = [UIAlertController alertControllerWithTitle:cTitle message:cMessage…
Satre
  • 1,664
  • 2
  • 14
  • 22
31
votes
6 answers

Controlling which view controller loads after receiving a push notification in SWIFT

Once I receive a push notification and swipe to open it, it just opens my app and not the VC I want. So my question is how do I load the VC I want? I know if the app is open I would move the VC over to another inside the didReceiveRemoteNotification…
Henry Brown
  • 2,079
  • 6
  • 26
  • 45
30
votes
1 answer

Swift 4 ,must be used from main thread only warning

When I using Swift4in Xcode 9 gives me UIApplication.delegate must be used from main thread only .... must be used from main thread only UI API called from background thread Group Purple Warning. My codes; var appDelegate =…
SwiftDeveloper
  • 6,588
  • 11
  • 50
  • 75
30
votes
5 answers

Open a view controller when a iOS push notification is received

I want to open a specific view controller when a user clicks on the received push notification message, but when I receive a push notification message and click the message, only the application opens, but it does not redirect to a specific view…
cdsoft
  • 611
  • 2
  • 8
  • 14
29
votes
2 answers

Swift – Instantiating a navigation controller without storyboards in App Delegate

I'm rebuilding an app without storyboards and the part of it that I'm having the most trouble with is navigating view-to-view programatically. Few things are written out there which don't use storyboards, so finding an answer for this has been…
Zack Shapiro
  • 5,202
  • 14
  • 65
  • 121
28
votes
3 answers

Present view controller from app delegate

I'm attempting to present a view controller from the app delegate with this code: - (void)interstitialViewControllerRequestSucceeded:(UIViewController *)interstitialViewController { [self.window.rootViewController…
mikeholp
  • 925
  • 3
  • 11
  • 14
27
votes
4 answers

How to convert Objective-C App Delegate to Swift?

I am working on old projects converting all classes to Swift. How can I convert the AppDelegate class to Swift? What changes must me made in the Project settings or main.m?
NSLog
  • 589
  • 1
  • 4
  • 11
26
votes
7 answers

Swift - pushViewController from appDelegate, rootViewController.navigationController is nil

Having a problem following a few guides, specifically http://blog.originate.com/blog/2014/04/22/deeplinking-in-ios/ I'm setting the url scheme and it's working well to launch the app from another app, but passing in the host or url are not working…
tehfailsafe
  • 2,491
  • 3
  • 18
  • 27
1
2 3
99 100