Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6765673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:44:22+00:00 2026-05-26T14:44:22+00:00

Ok, I’m still pretty new to iOS development, so I apologize if this is

  • 0

Ok, I’m still pretty new to iOS development, so I apologize if this is a silly question.

But, I have an AlertView that I call from the AppDelegate then respond when clicking a button in the alert. I can do a NSLog and see that the methods are getting called. But, it’s not pushing the view into the stack. Here’s a sample of what I have (I’m sure it’s wrong):

This is in the AppDelegate.m:

#import "AppDelegate.h"
#import "ProfileConnection.h"

@implementation AppDelegate

@synthesize window = _window;
@synthesize navController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.    
return YES;
}

-(void)switchToController:(NSString *)controller animated:(BOOL)animated{

NSLog(@"switching to controller %@", controller);

// maybe we can do a check to see if a subview exists...and then push or pop accordingly.

// switch to the "TableView" view
if( [controller isEqualToString:@"ProfileConnection"]){
    NSLog(@"switching to the ProfileConnection view");

    ProfileConnection *profile = [[ProfileConnection alloc] initWithNibName:@"ProfileConnection" bundle:nil];
    [self.navController pushViewController:profile animated:YES];

}
}

-(void)showConnectionFoundAlert
{
NSString *connectFoundMsg = [[NSString alloc] initWithFormat:@"We found someone we'd think you would like to meet:  Tony Davis"];
UIAlertView *connectionFoundAlert = [[UIAlertView alloc] initWithTitle:@"Connection Found" message:connectFoundMsg delegate:self cancelButtonTitle:@"Decline" otherButtonTitles:@"Connect", @"View Profile", @"Save For Later", nil];
[connectionFoundAlert show];
//[connectionFoundAlert release];

}

-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
NSString *alertString = [[NSString alloc] initWithFormat:@""];

if([title isEqualToString:@"Decline"])
{
    alertString = @"Declied";
}
else if([title isEqualToString:@"Connect"])
{
    alertString = @"Connected";
}
else if([title isEqualToString:@"View Profile"])
{
    //alertString = @"Profile Viewed";
    //NSLog(@"View Profile is being called");

    [self switchToController:@"ProfileConnection" animated:YES];

    //UIViewController *profile = [[UIViewController alloc] initWithNibName:@"ProfileConnection" bundle:nil];
    //ProfileConnection *profile = [[ProfileConnection alloc] initWithNibName:@"ProfileConnection" bundle:[NSBundle mainBundle]];
    //UINavigationController *nav = [[UINavigationController alloc] init];
    //[nav pushViewController:profile animated:NO];


    /*UIViewController *profile = [[UIViewController alloc] initWithNibName:@"ProfileConnection" bundle:nil];
    UINavigationController *navigation = [[UINavigationController alloc] init];
    [navigation pushViewController:profile animated:YES];*/

    /*
    ProfileConnection *profile = [ProfileConnection alloc];
    //UIView *current = self.window;
    [self.window addSubview:profile.view];
    */
    /*
    [window addSubview:view1.view];
    [window makeKeyAndVisible];

    - (void)goToNextPage {
        view2 = [ViewController2 alloc];   
        UIView *current = self.window;
        [self.window addSubview:view2.view];
    */

}
else if ([title isEqualToString:@"Save For Later"])
{
    alertString = @"Saved It";
}

UIAlertView *alertStr = [[UIAlertView alloc] initWithTitle:@"" message:alertString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

if ([alertString isEqualToString:@""]) {

} else {
    [alertStr show];        
}
}

@end

This is the AppDelegate.h:

#import <UIKit/UIKit.h>
#import "ProfileConnection.h"

@interface AppDelegate : UIResponder <UIAlertViewDelegate, UIApplicationDelegate, UINavigationControllerDelegate> {
UINavigationController *navController;
}

@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, retain) UINavigationController *navController;

-(void)showConnectionFoundAlert;
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex;
-(void)switchToController:(NSString *)controller animated:(BOOL)animated;

@end

I am able to add the view with this, but I lose my navigation controller:

ProfileConnection *profile = [ProfileConnection alloc];
[self.window addSubview:profile.view];

You can see I have tried a few approaches, but I’m confusing myself trying to use the storyboard approach.

Also, the ProfileConnection view is blank with a single label at the moment, if that helps.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:44:23+00:00Added an answer on May 26, 2026 at 2:44 pm

    You code looks ok [self.navController pushViewController:profile animated:YES]; is how you should do it.

    You should make sure that you have added the navigation controller to the window. Perhaps this should already be done by the storyboard, but if not user the rootviewcontroller property of the window (its better than addSubview).

    self.window.rootViewContorller = self.navController;
    

    Now do a sanity check to make sure nothing is nil (profile or the navController).

    NSLog(@"%@ %@",self.navController, profile);
    

    Does any of that help?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.