0

I have added a ViewvController(B) as subview on ViewController(A). In ViewController A(SuperView) UIModelPresentationFullScreen working fine. But when am calling UIModelPresentationFull in ViewController B(SubView) it modelview showing in Portrait mode and that is also not fully viewed. How to solve this problem. Can any one help me please. I have tried 2 days.

This is what I tried in both the superview and subview...

picFBCapture *fbCapt = [[picFBCapture alloc] init];
//[self.navigationController pushViewController:fbCapt animated:YES];
//fbCapt.modalPresentationStyle = UIModalTransitionStyleFlipHorizontal;
fbCapt.modalTransitionStyle = UIModalPresentationFullScreen;
[self presentModalViewController:fbCapt animated:NO]; 
[fbCapt release]; 

Thanks in advance..

Yuvaraj.M
  • 9,741
  • 16
  • 71
  • 100
  • Hi friends. I changed my application flow, but still i didnt find the answer for this question, anyone can help me. Thanks. – Yuvaraj.M Jul 05 '11 at 08:15

2 Answers2

1

The problem is that if you add a view controller as a subview it's not connected to the view controller hierarchy and thus certain things doesn't work. You should avoid adding view controllers as subviews whenever possible, since this is not how Apple intend view controllers to be used, but sometimes it can't be avoided.

If this is one of those cases when it can't be avoided you should save a reference to view controller A in view controller B and then call presentModalViewController: on view controller A (that is connected to the view controller hierarchy) instead of self (view controller B, that isn't connected).

EDIT: In controller A you probably have code looking something like:

[self.view addSubview:controllerB.view];

In conjunction to this line add:

controllerB.controllerA = self;

I hope you know how to create properties, but if not here's a hint:

@property (nonatomic, assign) UIViewController *controllerA;

The rest you should be able to figure out using Google and the documentation.

Erik B
  • 40,889
  • 25
  • 119
  • 135
  • @Erik Band @HG's actually i have segmented controller in ViewControllerA. I have added Viewcontrollers B,C,D in Segmentcontroller. In Viewcontroller A i want to add another ViewcontrollerE. This is my task. I understand your answers but, am not familiar in iphone, ipad. I need your answer how to solve it. Is any sample code is there. Please... Save me... – Yuvaraj.M Jun 21 '11 at 04:00
  • I need thank you both for spot response. Really sorry for delay... Can you help me to solve my problem. it's very urgent task... – Yuvaraj.M Jun 21 '11 at 04:49
  • @Erik B i tried your way. When i remove viewcontroller B from A and called Modelviewcontroller it's work fine. But, it is not my task. I want to add ViewControllerB in A then call ModelViewController full screen in ViewcontrollerB. How to save a Reference to viewController A in Viewcontroller B can you help me? Please still am struggling? – Yuvaraj.M Jun 22 '11 at 07:15
  • @Yuvaraj.M, This is basic programming knowledge, so I would advice you to read an introductory book on Objective-C. I could certainly write the code for you and if it gets me an upvote and the accept it might be worth it, but for your own sake take the time to learn it. – Erik B Jun 22 '11 at 12:51
  • @Yuvaraj.M, I updated the answer with information on how to save a reference to view controller A in view controller B. – Erik B Jun 22 '11 at 12:58
  • @Erik B first accept my apologies. Really am new one for objective-C and XCode. So really am struggling with app developing. I will implement your code in my app. Thank you so much. Still am reading about XCode Objective-C. I will pick myself very soon. Thanks a lot. Please guide me friend. – Yuvaraj.M Jun 23 '11 at 04:55
  • @Erik thanks for your response but, still am struggling. I did your steps, still PresentModelViewController not showing in landscape fullscreen. I will attach my code below, i hope you to solve my problem. – Yuvaraj.M Jun 23 '11 at 09:30
  • (ViewControllerB add in ViewControllerA)piciPadAllFrames *picFrames= [[piciPadAllFrames alloc] init]; picFrames.view.frame = self.view.bounds; picFrames.captureScreen = self; // captureScreen is obj for ViewController init in piciPadAllFrames Class [self.view addSubview:picFrames.view]; In ViewControllerB: @property (nonatomic, assign) UIViewController *captureScreen; //piciPadAllFrames.h captureScreen = [[UIViewController alloc] init]; // piciPadAllFrames.m viewDidLoad – Yuvaraj.M Jun 23 '11 at 09:41
  • @Erik B it is continue of above one:-(ViewControllerC add as modalview in ViewControllerB) picScrollFrames *controller = [[picScrollFrames alloc] init]; controller.view.frame = self.view.superview.bounds; controller.modalTransitionStyle = UIModalPresentationFullScreen; [self presentModalViewController:controller animated:YES]; Am waiting for your solution friend. Please help me.... – Yuvaraj.M Jun 23 '11 at 09:45
  • @Erik B i posted my code for your review. I cant find out where am i wrong. I expecting your solution, it will solve my problem. Please help me... Thanks in advance.. ViewControllerA is in Appdelegate, ViewControllerB is add in UISegmentedController in ViewControllerA. Thanks again.... – Yuvaraj.M Jun 23 '11 at 09:46
  • hello friend. Still i didnt solved my problem. Just i changed application working flow. Then, am read more about Objective-c can you please explain how to solve this problem. I want to know the answer for future. Thanks. – Yuvaraj.M Jul 05 '11 at 08:17
0

You will have to handle viewController B's view in landscape by yourself. Since viewController B has been added as a subview, its view controller will not be handling its landscape orientation. The UIModalPresentationFullScreen style (landscape and portrait) will work only if viewController B is shown, ie not as subview but as a full view itself.

HG's
  • 818
  • 6
  • 22