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 12-26-2009, 02:41 PM   #2 (permalink)
kierster
Registered Member
 
kierster's Avatar
 
Join Date: Mar 2009
Location: Canada!
Posts: 261
kierster is on a distinguished road
Default

Quote:
Originally Posted by mikolo View Post
Hi,

i have defined two UIViews and one action in my UIViewController like this:

PHP Code:
#import <UIKit/UIKit.h>
#import "LoginView.h"
#import "ContactListView.h"

@interface NowHereViewController UIViewController {
    
IBOutlet LoginView *loginView;
    
IBOutlet ContactListView *contactListView;
        
}

-(
void)swichView:(id)sender;

@
end 

first i load the loginView in my view in NowHereViewController.m like this:

PHP Code:
- (void)viewDidLoad {
    
NSLog(@" ---- viewDidLoad ---- ");
    
    [
self.view addSubview:loginView];
    [
loginView initLoginView];
        [
super viewDidLoad];
    

now i want to call the function swichView in the NowHereViewController from the loginView again?

How can i do this?
Thanxxx for help.
I had this same problem myself.
There's probably an easier way but here's how I solved it.

Add this to your view.h file
Code:
NowHereViewController *controller;
Make it a property in the .h and synthesize it in the .m file.
You will use controller to access the controller.

In the viewDidLoad of your viewcontroller add this line:
Code:
self.view.controller = self;
This sends a pointer of your view controller to the view, so it can access it.

Just be careful with this though! If the viewcontroller is non-existent the view will crash when its calls for it. You need to ensure that if a new view is made it will also know of this change. I add a if(self.controller != nil) whenever I call the controller, just so that if I forget to set the controller, it won't ruin everything!

Hope it works for you!
__________________
Check out some of my apps:
Boltz ($0.99)
FreeBoltz (FREE)
Cross Digits ($2.99) [Universal!]
Cross Digits Lite (FREE) [Universal!]
Targets ($0.99) (Facebook | YouTube Demo)
Greg's Apps
kierster is offline   Reply With Quote
 

» Advertisements
» Online Users: 671
15 members and 656 guests
ADY, apatsufas, djbrooks111, Duncan C, iAppDeveloper, JoePitto, KarlJay, msovani, sacha1996, SLIC, smithdale87, smithms, spinyanteater, ukneeq, Xaphann
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,422
Threads: 94,017
Posts: 402,542
Top Poster: BrianSlick (7,978)
Welcome to our newest member, iAppDeveloper
Powered by vBadvanced CMPS v3.1.0

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