0

I have an ipad app.

I am trying to open view 2 (kind of push view) full with entire screen. how normally do with push view or UIModalPresentationFullScreen. but my base view which is view 1 is also modal view.

so i was trying to open view 2 when view 1 get dismiss…

- (void) handleNewButton :(int)id
{
               [self dismissViewControllerAnimated:YES
                                 completion:^{
                                     NewViewController *View2 = [NewViewController alloc] init];
                                    View2.modalPresentationStyle = UIModalPresentationFullScreen;
                                     View2.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

                                     [self presentViewController: View2 animated:YES completion:nil];

                                 }];

 }

but my view 2 is not opening. i know i can not do push view. But is there any way to achieve it?.

san
  • 3,350
  • 1
  • 28
  • 40
user2813740
  • 517
  • 1
  • 7
  • 29

2 Answers2

0

When you do this dismissViewControllerAnimated the UIViewController (self in this case) is gone, in the sense that he is not on the screen anymore, if it has been released or not, that's another story. The reason for you to not be able to show the View2 (very poor name, it should at least ViewController2) is because you are trying to show it from a UIViewController that is not on the screen anymore.

So, what can you do?

The current self in the context of the handleNewButton method, in theory was presented by another UIViewController, that's from where you want to present your View2.

Probably the quickest way of implementing of what I said, would probably be with a notification described here. Although I would do it with a block, so when the self would be created, I would pass a dismissiCompletionBlock that would be called when that UIViewController was dismissed.

Community
  • 1
  • 1
Rui Peres
  • 25,741
  • 9
  • 87
  • 137
  • yes name i gave only for asking question(as i had mention view 2) i have my proper naming for my App…. i even tried saving the main view where my view 1 is presented and while dismissing view1.. push view on main view…but i did not get desire result... – user2813740 Jan 15 '14 at 12:06
  • [self dismissViewControllerAnimated:YES completion:^{ NewViewController *View2 = [NewViewController alloc] init]; View2.modalPresentationStyle = UIModalPresentationFullScreen; View2.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; [m_vwMainPage.navigationController pushViewController:partDataView animated:YES]; }]; – user2813740 Jan 15 '14 at 12:07
  • I achieved this with above code .. saving main view to View1 and pushing view2 while dismiss view1…. is there any better way to do this…as i have to save copy of my main view…. – user2813740 Jan 15 '14 at 12:14
  • Yes, I explained on my answer two aways of doing it. – Rui Peres Jan 15 '14 at 12:27
0

try to allocate NewViewController with nib name if you are not using storyboard,

 [self dismissViewControllerAnimated:YES
                                 completion:^{
        NewViewController *n=[[NewViewController alloc]initWithNibName:@"NewViewController" bundle:nil];

          View2.modalPresentationStyle = UIModalPresentationFullScreen;
          View2.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
          [self presentViewController: View2 animated:YES completion:nil];

                            }];

or if you are using storyboard get NewViewController using identifier.

Toseef Khilji
  • 17,192
  • 12
  • 80
  • 121