PresentModalViewController from UIView

I am trying to call presentModalViewController on a UIViewController to call the "View" address book, however I am facing some problem. The UIViewController, which "controls" the application, simply draws the view to the screen and then lets the view do all of the user interaction processing and so on. But now I need to somehow return the feedback to the UIViewController in order to call the presentModalViewController on the topic. Anyone have any ideas how to do this?

Thanks for any help!

+2


source to share


3 answers


Assuming your UIView controller is subclassed, you can add a property to it.

@interface MyView : UIView
{
    UIViewController *parentController;
}

// Don't use retain or you'll have a circular reference
@property(nonatomic, assign) UIViewController *parentController;

@end

      

Then, in your UIViewController code, assign self to the property parentController

.



-(void)viewDidLoad
{
    myView.parentController = self;
}

      

Is this what you were? However, the question is, why is your view controller not controlling your opinion?

+12


source


I would suggest giving your custom class a kind of delegate that will allow it to ask the delegate for some address book information. The delegate in this case would be the view controller, which would respond by showing the collector and then return the result.



0


source


Your UIView should fire an event (using the template used in UIButtons, etc.) for the delegate (either by protocol or using a specific selector).

If this is not possible, view.nextResponder should be your UIViewController if the view was created by a UIViewController.

0


source







All Articles