Today I tried to call on a viewcontroller:
-(void) Presentmodalviewcontroller: (Uiviewcontroller *) Modalviewcontroller animated: (BOOL) animated
To show a translucent viewcontroller:
Uiviewcontroller *VC = [[[Uiviewcontroller alloc] init] autorelease];
Vc.view.backgroundColor = [Uicolor colorwithred:0 green:0 blue:0 alpha:0.5];
[Self PRESENTMODALVIEWCONTROLLER:VC animated:yes];
This can be found in the animation process is translucent, but after the end of the animation will not see the content of the following Viewcontroller, black.
Why, then? Search for a more reasonable conclusion:
The "problem" is this iOS is very finicky about not wasting memory,
And since the modal view would completely cover the one beneath it,
It doesn ' t make much sense to keep it loaded.
Therefore, IOS unloads the view that presents the modal one.
You could check this behavior by implementing-viewwilldisappear:and-viewdiddisappear:.
Finally find a problem in so, and a workable solution:
ViewController.view.backgroundColor = [Uicolor clearcolor];
Rootviewcontroller.modalpresentationstyle = Uimodalpresentationcurrentcontext;
[Rootviewcontroller Presentmodalviewcontroller:viewcontroller Animated:yes];
Here are two points: one is to set Modalpresentationstyle as Uimodalpresentationcurrentcontext, and the second is to operate on Rootviewcontroller.