I don't have much experience with UIKit so I apologise in advance but I have an OpenGL game where I want to add a UIWebView to overlay some scrollable instructions. I am using the latest OpenGL ES template which has a UIViewController which has it's view set to EAGLView.
What I have done is a create a WebView.xib and added a UIWebView along with a UIToolbar. The UIToolbar has a "Back" button which when pressed will remove the view.
I have connected the UIWebView and UIToolbar using IB and connected the button to a press event.
I have created a new class called WebView which subclasses UIView and which is connected to the xib File's Owner.
Now in my ViewController I instanciate the WebView class like so.
Code:
webView = [[WebView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
I have a method in WebView which should animate the view in
Code:
- (void)addWebPageToView:(UIView *) view
{
NSLog(@"addWebPageToView");
[UIView beginAnimations:Nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:view cache:YES];
[view addSubview:self];
[UIView commitAnimations];
}
To show it (from C++ code) I use the following method
Code:
void showInstructions(const string& fileName)
{
MyAppDelegate *appDelegate = (MyAppDelegate *)[UIApplication sharedApplication].delegate;
MyViewController *viewController = [appDelegate viewController];
WebView *webView = viewController.webView;
[webPage createWebView:[NSString stringWithUTF8String:fileName.c_str()]];
[webView addWebPageToView:viewController.view];
}
The EAGLView does spin around like it's animating correctly but the view is never shown.