从UIView的presentModalViewController [英] presentModalViewController from UIView

查看:139
本文介绍了从UIView的presentModalViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在UIViewController调用presentModalViewController为了提出一个地址簿视图,但我遇到一个问题。 UIViewController控制应用程序只是绘制一个视图到屏幕,然后让视图做所有的处理用户交互等等。但现在,我需要以某种方式回溯到UIViewController为了调用presentModalViewController在上面。

I am attempting to call presentModalViewController on a UIViewController in order to bring up a Address Book "view", however I am running into a bit of a problem. The UIViewController that "controls" the app simply draws a view to the screen and then lets the view do all of the handling of user interaction, etc. But now, I need to somehow need to back track to the UIViewController in order to call presentModalViewController on it. Would anyone have any ideas of how to accomplish this?

感谢您的帮助!

推荐答案

假设你的控制器的UIView是子类,你可以添加一个属性。

Assuming your controller's UIView is subclassed, you could 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

然后在您的UIViewController代码中将self赋予 parentController 属性。

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

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

这是你的吗?问题来了,为什么你的视图不是控制你的视图

Is this what you were after? Begs the question though, why isn't your view controller not controlling your view?

这篇关于从UIView的presentModalViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆