Push View Controller, Black Screen












20















I'm pushing to a new view controller and passing some data to it. When I run the application I can press the button and push to a new view but the screen is completely black. Any help is appreciated.



- (IBAction)button:(id)sender {

NSString *firstField = self.field.text;
NSString *secondField = self.field2.text;

self.resultsArray = [[NSArray alloc] initWithObjects:firstField, secondField, nil];

NSUInteger randomResult = arc4random_uniform(self.resultsArray.count);
self.label.text = [self.resultsArray objectAtIndex:randomResult];

ImagesViewController *ivc = [[ImagesViewController alloc] init];
ivc.label = self.label.text;
[self.navigationController pushViewController:ivc animated:YES];

}









share|improve this question

























  • what is the context of this ? are you allocating the view controller from storyboard? a xib file? no thing at all just randomly?

    – A'sa Dickens
    Jul 25 '13 at 15:21
















20















I'm pushing to a new view controller and passing some data to it. When I run the application I can press the button and push to a new view but the screen is completely black. Any help is appreciated.



- (IBAction)button:(id)sender {

NSString *firstField = self.field.text;
NSString *secondField = self.field2.text;

self.resultsArray = [[NSArray alloc] initWithObjects:firstField, secondField, nil];

NSUInteger randomResult = arc4random_uniform(self.resultsArray.count);
self.label.text = [self.resultsArray objectAtIndex:randomResult];

ImagesViewController *ivc = [[ImagesViewController alloc] init];
ivc.label = self.label.text;
[self.navigationController pushViewController:ivc animated:YES];

}









share|improve this question

























  • what is the context of this ? are you allocating the view controller from storyboard? a xib file? no thing at all just randomly?

    – A'sa Dickens
    Jul 25 '13 at 15:21














20












20








20


7






I'm pushing to a new view controller and passing some data to it. When I run the application I can press the button and push to a new view but the screen is completely black. Any help is appreciated.



- (IBAction)button:(id)sender {

NSString *firstField = self.field.text;
NSString *secondField = self.field2.text;

self.resultsArray = [[NSArray alloc] initWithObjects:firstField, secondField, nil];

NSUInteger randomResult = arc4random_uniform(self.resultsArray.count);
self.label.text = [self.resultsArray objectAtIndex:randomResult];

ImagesViewController *ivc = [[ImagesViewController alloc] init];
ivc.label = self.label.text;
[self.navigationController pushViewController:ivc animated:YES];

}









share|improve this question
















I'm pushing to a new view controller and passing some data to it. When I run the application I can press the button and push to a new view but the screen is completely black. Any help is appreciated.



- (IBAction)button:(id)sender {

NSString *firstField = self.field.text;
NSString *secondField = self.field2.text;

self.resultsArray = [[NSArray alloc] initWithObjects:firstField, secondField, nil];

NSUInteger randomResult = arc4random_uniform(self.resultsArray.count);
self.label.text = [self.resultsArray objectAtIndex:randomResult];

ImagesViewController *ivc = [[ImagesViewController alloc] init];
ivc.label = self.label.text;
[self.navigationController pushViewController:ivc animated:YES];

}






ios uiviewcontroller






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 25 '13 at 15:41









9to5ios

3,16522153




3,16522153










asked Jul 25 '13 at 15:12









Brandon HoulihanBrandon Houlihan

104116




104116













  • what is the context of this ? are you allocating the view controller from storyboard? a xib file? no thing at all just randomly?

    – A'sa Dickens
    Jul 25 '13 at 15:21



















  • what is the context of this ? are you allocating the view controller from storyboard? a xib file? no thing at all just randomly?

    – A'sa Dickens
    Jul 25 '13 at 15:21

















what is the context of this ? are you allocating the view controller from storyboard? a xib file? no thing at all just randomly?

– A'sa Dickens
Jul 25 '13 at 15:21





what is the context of this ? are you allocating the view controller from storyboard? a xib file? no thing at all just randomly?

– A'sa Dickens
Jul 25 '13 at 15:21












7 Answers
7






active

oldest

votes


















48














When you're using a storyboard, and you want to push a view controller in code (rather than with a segue), you need to give the controller an identifier, and create it like this:



    ImagesViewController *ivc = [self.storyboard instantiateViewControllerWithIdentifier:@"MyIdentifier"];
ivc.label = self.label.text;
[self.navigationController pushViewController:ivc animated:YES];





share|improve this answer


























  • The storyboard object can be retrieved with [UIStoryboard storyboardWithName:@"Main" bundle: nil]; where "Main" is the storyboard's filename without the extension (so could also be "Main_iPhone" or "Main_iPad").

    – Brian White
    Feb 7 '14 at 21:36











  • @BrianWhite, true, but if the calling controller is in the same storyboard as the new controller, it's shorter to just use self.storyboard.

    – rdelmar
    Feb 7 '14 at 22:37











  • Sure. I was trying to access it from the AppDelegate which did not have that property and so had to do some more searching. I figured I'd append what I learned so others might avoid the extra work if they were trying to do the same.

    – Brian White
    Feb 8 '14 at 1:52











  • Anyone that tried this and had the "Expected ']'" warning, put a ':'before "@MyIdentifier", so it will stay like this: instantiateViewControllerWithIdentifier:@"MyIdentifier"

    – Rodrigo Venancio
    Mar 27 '14 at 14:57











  • @RodrigoVenancio, thanks for catching that typo. I've corrected the post.

    – rdelmar
    Mar 27 '14 at 15:04



















2














The view controller you are pushing is not having any frame dimension set.It is always recommended to call designated init for objects. For view controllers, designated init method is



- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle


if you have a xib assign it like



ImagesViewController *ivc = [[ImagesViewController alloc] initWithNibName:<your xib> bundle:[NSBundle mainbundle];


if you are using custom view, assign a frame dimension and add it as subview






share|improve this answer































    2














    Xcode 7.3 and Swift 2.2



    In my case, I had made changes in the storyboard and made it a TabBarController and accordingly changed the class of the controller from UIViewController to UITabBarController. After some tweaking, this change wasn't favourable and I un did all the changes and got a black screen then because I had forgotten to change the class of the controller. I changed it back to UIViewController and it started working again.



    So check if you have made the same mistake. The black screen came because the storyboard had a class(UIView/UITabBar/UITableView Controller) but that wasnt the same in code.






    share|improve this answer































      1














      This can also happen if you have somehow got an incorrect connection between one of the subviews in the storyboard to the controller's view. Check the Referencing Outlets are correct in each of your subviews.






      share|improve this answer































        1














        I got a good one:



        Make sure you are implementing the right Super class, delegate, etc.. in the top part of the viewController you are trying to present. i.e.



        I wasn't using/implementing UINavigationController at all



        class TMDetailBlogViewController: UINavigationController {
        //code goes here
        }


        After



        class TMDetailBlogViewController: UIViewController {
        //code goes here
        }





        share|improve this answer































          0














          Typically, you transition to another view controller by calling:



          initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil


          on your custom UIViewController.



          If you're not using a xib file, then what you're doing may be fine. Are you dynamically creating your UI elements within the constructor of your ImagesViewController?






          share|improve this answer
























          • I don't have a xib. I'm creating the UI elements from the storyboard.

            – Brandon Houlihan
            Jul 25 '13 at 15:50











          • In that case, you probably want to make use of this method to handle your view transition: - (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender

            – Paul Dardeau
            Jul 25 '13 at 15:53





















          0














          I was trying without using storyboard, and its just that the default screen it uses is in black color. I changed the background color to white and it worked.



          Pushed the controller this way-



          NextController *nextController = [[NextController alloc]init];
          [self.navigationController pushViewController:nextController animated:YES];



          In NextController-



          (void)viewDidLoad{
          [self.view setBackgroundColor:[UIColor whiteColor]];


          }






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17861940%2fpush-view-controller-black-screen%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            7 Answers
            7






            active

            oldest

            votes








            7 Answers
            7






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            48














            When you're using a storyboard, and you want to push a view controller in code (rather than with a segue), you need to give the controller an identifier, and create it like this:



                ImagesViewController *ivc = [self.storyboard instantiateViewControllerWithIdentifier:@"MyIdentifier"];
            ivc.label = self.label.text;
            [self.navigationController pushViewController:ivc animated:YES];





            share|improve this answer


























            • The storyboard object can be retrieved with [UIStoryboard storyboardWithName:@"Main" bundle: nil]; where "Main" is the storyboard's filename without the extension (so could also be "Main_iPhone" or "Main_iPad").

              – Brian White
              Feb 7 '14 at 21:36











            • @BrianWhite, true, but if the calling controller is in the same storyboard as the new controller, it's shorter to just use self.storyboard.

              – rdelmar
              Feb 7 '14 at 22:37











            • Sure. I was trying to access it from the AppDelegate which did not have that property and so had to do some more searching. I figured I'd append what I learned so others might avoid the extra work if they were trying to do the same.

              – Brian White
              Feb 8 '14 at 1:52











            • Anyone that tried this and had the "Expected ']'" warning, put a ':'before "@MyIdentifier", so it will stay like this: instantiateViewControllerWithIdentifier:@"MyIdentifier"

              – Rodrigo Venancio
              Mar 27 '14 at 14:57











            • @RodrigoVenancio, thanks for catching that typo. I've corrected the post.

              – rdelmar
              Mar 27 '14 at 15:04
















            48














            When you're using a storyboard, and you want to push a view controller in code (rather than with a segue), you need to give the controller an identifier, and create it like this:



                ImagesViewController *ivc = [self.storyboard instantiateViewControllerWithIdentifier:@"MyIdentifier"];
            ivc.label = self.label.text;
            [self.navigationController pushViewController:ivc animated:YES];





            share|improve this answer


























            • The storyboard object can be retrieved with [UIStoryboard storyboardWithName:@"Main" bundle: nil]; where "Main" is the storyboard's filename without the extension (so could also be "Main_iPhone" or "Main_iPad").

              – Brian White
              Feb 7 '14 at 21:36











            • @BrianWhite, true, but if the calling controller is in the same storyboard as the new controller, it's shorter to just use self.storyboard.

              – rdelmar
              Feb 7 '14 at 22:37











            • Sure. I was trying to access it from the AppDelegate which did not have that property and so had to do some more searching. I figured I'd append what I learned so others might avoid the extra work if they were trying to do the same.

              – Brian White
              Feb 8 '14 at 1:52











            • Anyone that tried this and had the "Expected ']'" warning, put a ':'before "@MyIdentifier", so it will stay like this: instantiateViewControllerWithIdentifier:@"MyIdentifier"

              – Rodrigo Venancio
              Mar 27 '14 at 14:57











            • @RodrigoVenancio, thanks for catching that typo. I've corrected the post.

              – rdelmar
              Mar 27 '14 at 15:04














            48












            48








            48







            When you're using a storyboard, and you want to push a view controller in code (rather than with a segue), you need to give the controller an identifier, and create it like this:



                ImagesViewController *ivc = [self.storyboard instantiateViewControllerWithIdentifier:@"MyIdentifier"];
            ivc.label = self.label.text;
            [self.navigationController pushViewController:ivc animated:YES];





            share|improve this answer















            When you're using a storyboard, and you want to push a view controller in code (rather than with a segue), you need to give the controller an identifier, and create it like this:



                ImagesViewController *ivc = [self.storyboard instantiateViewControllerWithIdentifier:@"MyIdentifier"];
            ivc.label = self.label.text;
            [self.navigationController pushViewController:ivc animated:YES];






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 27 '14 at 15:04

























            answered Jul 25 '13 at 16:19









            rdelmarrdelmar

            98.8k10191209




            98.8k10191209













            • The storyboard object can be retrieved with [UIStoryboard storyboardWithName:@"Main" bundle: nil]; where "Main" is the storyboard's filename without the extension (so could also be "Main_iPhone" or "Main_iPad").

              – Brian White
              Feb 7 '14 at 21:36











            • @BrianWhite, true, but if the calling controller is in the same storyboard as the new controller, it's shorter to just use self.storyboard.

              – rdelmar
              Feb 7 '14 at 22:37











            • Sure. I was trying to access it from the AppDelegate which did not have that property and so had to do some more searching. I figured I'd append what I learned so others might avoid the extra work if they were trying to do the same.

              – Brian White
              Feb 8 '14 at 1:52











            • Anyone that tried this and had the "Expected ']'" warning, put a ':'before "@MyIdentifier", so it will stay like this: instantiateViewControllerWithIdentifier:@"MyIdentifier"

              – Rodrigo Venancio
              Mar 27 '14 at 14:57











            • @RodrigoVenancio, thanks for catching that typo. I've corrected the post.

              – rdelmar
              Mar 27 '14 at 15:04



















            • The storyboard object can be retrieved with [UIStoryboard storyboardWithName:@"Main" bundle: nil]; where "Main" is the storyboard's filename without the extension (so could also be "Main_iPhone" or "Main_iPad").

              – Brian White
              Feb 7 '14 at 21:36











            • @BrianWhite, true, but if the calling controller is in the same storyboard as the new controller, it's shorter to just use self.storyboard.

              – rdelmar
              Feb 7 '14 at 22:37











            • Sure. I was trying to access it from the AppDelegate which did not have that property and so had to do some more searching. I figured I'd append what I learned so others might avoid the extra work if they were trying to do the same.

              – Brian White
              Feb 8 '14 at 1:52











            • Anyone that tried this and had the "Expected ']'" warning, put a ':'before "@MyIdentifier", so it will stay like this: instantiateViewControllerWithIdentifier:@"MyIdentifier"

              – Rodrigo Venancio
              Mar 27 '14 at 14:57











            • @RodrigoVenancio, thanks for catching that typo. I've corrected the post.

              – rdelmar
              Mar 27 '14 at 15:04

















            The storyboard object can be retrieved with [UIStoryboard storyboardWithName:@"Main" bundle: nil]; where "Main" is the storyboard's filename without the extension (so could also be "Main_iPhone" or "Main_iPad").

            – Brian White
            Feb 7 '14 at 21:36





            The storyboard object can be retrieved with [UIStoryboard storyboardWithName:@"Main" bundle: nil]; where "Main" is the storyboard's filename without the extension (so could also be "Main_iPhone" or "Main_iPad").

            – Brian White
            Feb 7 '14 at 21:36













            @BrianWhite, true, but if the calling controller is in the same storyboard as the new controller, it's shorter to just use self.storyboard.

            – rdelmar
            Feb 7 '14 at 22:37





            @BrianWhite, true, but if the calling controller is in the same storyboard as the new controller, it's shorter to just use self.storyboard.

            – rdelmar
            Feb 7 '14 at 22:37













            Sure. I was trying to access it from the AppDelegate which did not have that property and so had to do some more searching. I figured I'd append what I learned so others might avoid the extra work if they were trying to do the same.

            – Brian White
            Feb 8 '14 at 1:52





            Sure. I was trying to access it from the AppDelegate which did not have that property and so had to do some more searching. I figured I'd append what I learned so others might avoid the extra work if they were trying to do the same.

            – Brian White
            Feb 8 '14 at 1:52













            Anyone that tried this and had the "Expected ']'" warning, put a ':'before "@MyIdentifier", so it will stay like this: instantiateViewControllerWithIdentifier:@"MyIdentifier"

            – Rodrigo Venancio
            Mar 27 '14 at 14:57





            Anyone that tried this and had the "Expected ']'" warning, put a ':'before "@MyIdentifier", so it will stay like this: instantiateViewControllerWithIdentifier:@"MyIdentifier"

            – Rodrigo Venancio
            Mar 27 '14 at 14:57













            @RodrigoVenancio, thanks for catching that typo. I've corrected the post.

            – rdelmar
            Mar 27 '14 at 15:04





            @RodrigoVenancio, thanks for catching that typo. I've corrected the post.

            – rdelmar
            Mar 27 '14 at 15:04













            2














            The view controller you are pushing is not having any frame dimension set.It is always recommended to call designated init for objects. For view controllers, designated init method is



            - (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle


            if you have a xib assign it like



            ImagesViewController *ivc = [[ImagesViewController alloc] initWithNibName:<your xib> bundle:[NSBundle mainbundle];


            if you are using custom view, assign a frame dimension and add it as subview






            share|improve this answer




























              2














              The view controller you are pushing is not having any frame dimension set.It is always recommended to call designated init for objects. For view controllers, designated init method is



              - (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle


              if you have a xib assign it like



              ImagesViewController *ivc = [[ImagesViewController alloc] initWithNibName:<your xib> bundle:[NSBundle mainbundle];


              if you are using custom view, assign a frame dimension and add it as subview






              share|improve this answer


























                2












                2








                2







                The view controller you are pushing is not having any frame dimension set.It is always recommended to call designated init for objects. For view controllers, designated init method is



                - (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle


                if you have a xib assign it like



                ImagesViewController *ivc = [[ImagesViewController alloc] initWithNibName:<your xib> bundle:[NSBundle mainbundle];


                if you are using custom view, assign a frame dimension and add it as subview






                share|improve this answer













                The view controller you are pushing is not having any frame dimension set.It is always recommended to call designated init for objects. For view controllers, designated init method is



                - (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle


                if you have a xib assign it like



                ImagesViewController *ivc = [[ImagesViewController alloc] initWithNibName:<your xib> bundle:[NSBundle mainbundle];


                if you are using custom view, assign a frame dimension and add it as subview







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jul 25 '13 at 15:29









                slysidslysid

                1,87832244




                1,87832244























                    2














                    Xcode 7.3 and Swift 2.2



                    In my case, I had made changes in the storyboard and made it a TabBarController and accordingly changed the class of the controller from UIViewController to UITabBarController. After some tweaking, this change wasn't favourable and I un did all the changes and got a black screen then because I had forgotten to change the class of the controller. I changed it back to UIViewController and it started working again.



                    So check if you have made the same mistake. The black screen came because the storyboard had a class(UIView/UITabBar/UITableView Controller) but that wasnt the same in code.






                    share|improve this answer




























                      2














                      Xcode 7.3 and Swift 2.2



                      In my case, I had made changes in the storyboard and made it a TabBarController and accordingly changed the class of the controller from UIViewController to UITabBarController. After some tweaking, this change wasn't favourable and I un did all the changes and got a black screen then because I had forgotten to change the class of the controller. I changed it back to UIViewController and it started working again.



                      So check if you have made the same mistake. The black screen came because the storyboard had a class(UIView/UITabBar/UITableView Controller) but that wasnt the same in code.






                      share|improve this answer


























                        2












                        2








                        2







                        Xcode 7.3 and Swift 2.2



                        In my case, I had made changes in the storyboard and made it a TabBarController and accordingly changed the class of the controller from UIViewController to UITabBarController. After some tweaking, this change wasn't favourable and I un did all the changes and got a black screen then because I had forgotten to change the class of the controller. I changed it back to UIViewController and it started working again.



                        So check if you have made the same mistake. The black screen came because the storyboard had a class(UIView/UITabBar/UITableView Controller) but that wasnt the same in code.






                        share|improve this answer













                        Xcode 7.3 and Swift 2.2



                        In my case, I had made changes in the storyboard and made it a TabBarController and accordingly changed the class of the controller from UIViewController to UITabBarController. After some tweaking, this change wasn't favourable and I un did all the changes and got a black screen then because I had forgotten to change the class of the controller. I changed it back to UIViewController and it started working again.



                        So check if you have made the same mistake. The black screen came because the storyboard had a class(UIView/UITabBar/UITableView Controller) but that wasnt the same in code.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Jun 2 '16 at 6:16









                        Yash TamakuwalaYash Tamakuwala

                        6141116




                        6141116























                            1














                            This can also happen if you have somehow got an incorrect connection between one of the subviews in the storyboard to the controller's view. Check the Referencing Outlets are correct in each of your subviews.






                            share|improve this answer




























                              1














                              This can also happen if you have somehow got an incorrect connection between one of the subviews in the storyboard to the controller's view. Check the Referencing Outlets are correct in each of your subviews.






                              share|improve this answer


























                                1












                                1








                                1







                                This can also happen if you have somehow got an incorrect connection between one of the subviews in the storyboard to the controller's view. Check the Referencing Outlets are correct in each of your subviews.






                                share|improve this answer













                                This can also happen if you have somehow got an incorrect connection between one of the subviews in the storyboard to the controller's view. Check the Referencing Outlets are correct in each of your subviews.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Feb 25 '15 at 9:03









                                sdsykessdsykes

                                1,1961113




                                1,1961113























                                    1














                                    I got a good one:



                                    Make sure you are implementing the right Super class, delegate, etc.. in the top part of the viewController you are trying to present. i.e.



                                    I wasn't using/implementing UINavigationController at all



                                    class TMDetailBlogViewController: UINavigationController {
                                    //code goes here
                                    }


                                    After



                                    class TMDetailBlogViewController: UIViewController {
                                    //code goes here
                                    }





                                    share|improve this answer




























                                      1














                                      I got a good one:



                                      Make sure you are implementing the right Super class, delegate, etc.. in the top part of the viewController you are trying to present. i.e.



                                      I wasn't using/implementing UINavigationController at all



                                      class TMDetailBlogViewController: UINavigationController {
                                      //code goes here
                                      }


                                      After



                                      class TMDetailBlogViewController: UIViewController {
                                      //code goes here
                                      }





                                      share|improve this answer


























                                        1












                                        1








                                        1







                                        I got a good one:



                                        Make sure you are implementing the right Super class, delegate, etc.. in the top part of the viewController you are trying to present. i.e.



                                        I wasn't using/implementing UINavigationController at all



                                        class TMDetailBlogViewController: UINavigationController {
                                        //code goes here
                                        }


                                        After



                                        class TMDetailBlogViewController: UIViewController {
                                        //code goes here
                                        }





                                        share|improve this answer













                                        I got a good one:



                                        Make sure you are implementing the right Super class, delegate, etc.. in the top part of the viewController you are trying to present. i.e.



                                        I wasn't using/implementing UINavigationController at all



                                        class TMDetailBlogViewController: UINavigationController {
                                        //code goes here
                                        }


                                        After



                                        class TMDetailBlogViewController: UIViewController {
                                        //code goes here
                                        }






                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Oct 21 '16 at 20:54









                                        idelfonsogutierrezidelfonsogutierrez

                                        424




                                        424























                                            0














                                            Typically, you transition to another view controller by calling:



                                            initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil


                                            on your custom UIViewController.



                                            If you're not using a xib file, then what you're doing may be fine. Are you dynamically creating your UI elements within the constructor of your ImagesViewController?






                                            share|improve this answer
























                                            • I don't have a xib. I'm creating the UI elements from the storyboard.

                                              – Brandon Houlihan
                                              Jul 25 '13 at 15:50











                                            • In that case, you probably want to make use of this method to handle your view transition: - (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender

                                              – Paul Dardeau
                                              Jul 25 '13 at 15:53


















                                            0














                                            Typically, you transition to another view controller by calling:



                                            initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil


                                            on your custom UIViewController.



                                            If you're not using a xib file, then what you're doing may be fine. Are you dynamically creating your UI elements within the constructor of your ImagesViewController?






                                            share|improve this answer
























                                            • I don't have a xib. I'm creating the UI elements from the storyboard.

                                              – Brandon Houlihan
                                              Jul 25 '13 at 15:50











                                            • In that case, you probably want to make use of this method to handle your view transition: - (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender

                                              – Paul Dardeau
                                              Jul 25 '13 at 15:53
















                                            0












                                            0








                                            0







                                            Typically, you transition to another view controller by calling:



                                            initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil


                                            on your custom UIViewController.



                                            If you're not using a xib file, then what you're doing may be fine. Are you dynamically creating your UI elements within the constructor of your ImagesViewController?






                                            share|improve this answer













                                            Typically, you transition to another view controller by calling:



                                            initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil


                                            on your custom UIViewController.



                                            If you're not using a xib file, then what you're doing may be fine. Are you dynamically creating your UI elements within the constructor of your ImagesViewController?







                                            share|improve this answer












                                            share|improve this answer



                                            share|improve this answer










                                            answered Jul 25 '13 at 15:18









                                            Paul DardeauPaul Dardeau

                                            2,121189




                                            2,121189













                                            • I don't have a xib. I'm creating the UI elements from the storyboard.

                                              – Brandon Houlihan
                                              Jul 25 '13 at 15:50











                                            • In that case, you probably want to make use of this method to handle your view transition: - (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender

                                              – Paul Dardeau
                                              Jul 25 '13 at 15:53





















                                            • I don't have a xib. I'm creating the UI elements from the storyboard.

                                              – Brandon Houlihan
                                              Jul 25 '13 at 15:50











                                            • In that case, you probably want to make use of this method to handle your view transition: - (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender

                                              – Paul Dardeau
                                              Jul 25 '13 at 15:53



















                                            I don't have a xib. I'm creating the UI elements from the storyboard.

                                            – Brandon Houlihan
                                            Jul 25 '13 at 15:50





                                            I don't have a xib. I'm creating the UI elements from the storyboard.

                                            – Brandon Houlihan
                                            Jul 25 '13 at 15:50













                                            In that case, you probably want to make use of this method to handle your view transition: - (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender

                                            – Paul Dardeau
                                            Jul 25 '13 at 15:53







                                            In that case, you probably want to make use of this method to handle your view transition: - (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender

                                            – Paul Dardeau
                                            Jul 25 '13 at 15:53













                                            0














                                            I was trying without using storyboard, and its just that the default screen it uses is in black color. I changed the background color to white and it worked.



                                            Pushed the controller this way-



                                            NextController *nextController = [[NextController alloc]init];
                                            [self.navigationController pushViewController:nextController animated:YES];



                                            In NextController-



                                            (void)viewDidLoad{
                                            [self.view setBackgroundColor:[UIColor whiteColor]];


                                            }






                                            share|improve this answer




























                                              0














                                              I was trying without using storyboard, and its just that the default screen it uses is in black color. I changed the background color to white and it worked.



                                              Pushed the controller this way-



                                              NextController *nextController = [[NextController alloc]init];
                                              [self.navigationController pushViewController:nextController animated:YES];



                                              In NextController-



                                              (void)viewDidLoad{
                                              [self.view setBackgroundColor:[UIColor whiteColor]];


                                              }






                                              share|improve this answer


























                                                0












                                                0








                                                0







                                                I was trying without using storyboard, and its just that the default screen it uses is in black color. I changed the background color to white and it worked.



                                                Pushed the controller this way-



                                                NextController *nextController = [[NextController alloc]init];
                                                [self.navigationController pushViewController:nextController animated:YES];



                                                In NextController-



                                                (void)viewDidLoad{
                                                [self.view setBackgroundColor:[UIColor whiteColor]];


                                                }






                                                share|improve this answer













                                                I was trying without using storyboard, and its just that the default screen it uses is in black color. I changed the background color to white and it worked.



                                                Pushed the controller this way-



                                                NextController *nextController = [[NextController alloc]init];
                                                [self.navigationController pushViewController:nextController animated:YES];



                                                In NextController-



                                                (void)viewDidLoad{
                                                [self.view setBackgroundColor:[UIColor whiteColor]];


                                                }







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Jan 2 at 20:01









                                                Sneha Priya AleSneha Priya Ale

                                                113




                                                113






























                                                    draft saved

                                                    draft discarded




















































                                                    Thanks for contributing an answer to Stack Overflow!


                                                    • Please be sure to answer the question. Provide details and share your research!

                                                    But avoid



                                                    • Asking for help, clarification, or responding to other answers.

                                                    • Making statements based on opinion; back them up with references or personal experience.


                                                    To learn more, see our tips on writing great answers.




                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function () {
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17861940%2fpush-view-controller-black-screen%23new-answer', 'question_page');
                                                    }
                                                    );

                                                    Post as a guest















                                                    Required, but never shown





















































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown

































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown







                                                    Popular posts from this blog

                                                    MongoDB - Not Authorized To Execute Command

                                                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

                                                    How to fix TextFormField cause rebuild widget in Flutter