سؤال

I'm not even sure that it even matters whether or not the subview is an EAGLView, but I'll try to explain anyway:

In my application delegate didFinishLaunchingWithOptions() function, I have the following code (some parts omitted since I dont think theyre neessary):

    CGRect screenBounds = [[UIScreen mainScreen] bounds];

    window = [[UIWindow alloc] initWithFrame: screenBounds];

    view = [[EAGLView alloc] initWithFrame: viewBounds];

    [window addSubview:view];
    [window addSubview: overlayViewController.view];
    [window makeKeyAndVisible];

Now, I have some functions within view (the EAGLView) from which I would like to call some functions within the overlayViewController.

For example, within view, I might have some function:

-(void)doSomethingInViewController
{
   // somehow call a function within overlayViewController
}

Within that function defined in view, how can I access a function defined in overlayViewController? Thank you!

هل كانت مفيدة؟

المحلول

  1. Notifications - overlayViewController register for notification, EAGLView post it, overlayViewController receive it and call some method.

  2. Delegation - create overlayViewController delegate protocol, create delegate property in EAGLView, call delegate method directly on delegate (overlayViewController)

  3. Week reference - create assigned property of overlayViewController type in EAGLView for example

You have many core concepts of this kind of messaging ;)

But why not put EAGLView and overlay view into the same controller as subviews?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top