简体   繁体   中英

Making a reference to an UIViewController from an ObjectiveC class

So my question is: How to make a reference to a UIViewController from an outside ObjectiveC class. I have a ViewController, and a UIScrollView on it, and a class that needs to override some methods, and eventually return said UIScrollView. So, i figured that the easiest way to do this is to type:

return destinationViewController.scrollView;

but i don't quite know how to make the destinationViewController reference. Help?

You should be able to pass it as a parameter to the outside class, otherwise you should rethink your class design. In worst case, you can store it in AppDelegate or some specialized singleton (or public static field (like static UIViewController *g_ViewController) in the worst worst case)...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM