Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 07-01-2009, 11:00 AM   #10 (permalink)
iDoTouch
New Member
 
Join Date: Jun 2009
Location: Brookline, MA
Posts: 14
iDoTouch is on a distinguished road
Default

Quote:
Originally Posted by benoitr007 View Post
Thank you very much for the replies... Unfortunately I'm still confused. Haha.

iDoTouch: Thanks, but actually I can access the viewController in the AppDelegate since it's where the instance is created. What I want is access the viewController in the view object.

Artem: The problem is the view isn't initialized programmatically (as far as I know). I have told IB that the view of my view controller should be an object from the MainView class, but that's it. Everything seems to be done in the background. So where should I put that code? I want to keep my IB-made interface.

Also nobody really answered the question number 2 of my original post.

What I meant to say is that if you put the following code into your MainView.m file, then that is one way to access your view controller.

Say you have a MainView and a MainViewController.
MainViewController's "view" property is of the class "MainView"
In your MainView.m file, one way to access MainViewController (ie, the MainView's controller) is to insert the following code into your MainView.m file:

So, for example, if in my MainView, I want to call a method called "mainViewControllerMethod" of the MainViewController when the touchesEnded method of MainView is called, I would insert the following into MainView.m:

- (void)touchesEndedNSSet *)touches withEventUIEvent *)event
{
//Create a pointer to the delegate then access the mainViewController
MyAppDelegate *delegate=[[UIApplication sharedApplication] delegate];
[delegate.mainViewController mainViewControllerMethod];
}

Does that make more sense?
iDoTouch is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,639
Threads: 94,102
Posts: 402,830
Top Poster: BrianSlick (7,990)
Welcome to our newest member, sCarlRodriguezj
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:09 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.