开发者

Connecting UIViewControllers with a image using touchesBegan

I got a MainViewController who has addes a SubViewController.

In the SubViewController there another SubSubViewController who has image inside witch will be clicked sometimes.

When touchesBegan dispatch the delegate of SubSubViewController is getting called.

Now i need this.

[mainViewController method] inside the SubSubViewController. How do i connect to this parent?

Any help would be really nice!!

开发者_运维百科

Michiel


The best way is to use your AppDelegate.

[ (AppDelegate*)[ [ UIApplication sharedApplication ] delegate ] doSomething ];

Good Luck ! Vincent


You could do: [[subsubView superview] superview] to get a reference to your mainview. Or you could use a subclass for your subsubview and give it a property and set it to keep a reference to its super-viewcontroller upon creation.

Edit: Forget about superview, it works only for views, you're interested in viewcontrollers. Sorry I got you wrong. Try keeping a reference, besides using a property in the VC itself, you could store it in the appdelegate or another singleton to make it easy to access.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜