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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-09-2010, 03:55 PM   #1 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 6
Default UIViewController firing an event in another UIViewController

Hi

My iPhone app is made of of a main tabController with 4 main tabs. I have a situation where ViewController A loads ViewController B (using pushViewController). I now need to get back to ViewController A and and trigger an action on A from B.

Getting back to A is easy all I have to do is :-

self.tabBarController.selectedIndex = 0;
[self.navigationController popViewControllerAnimated:YES];

this then causes the ViewController A to be visible.

But how do I then get ViewController B to fire an action on A?

I have tried to use:-

ViewControllerA *aVC = ((ViewControllerA *)((UIViewController *)[self.tabBarC.tabBarController.viewControllers objectAtIndex:0]));
[aVC setAnnoSelected];

Only when I do that I get:-

-[UINavigationController setAnnoSelected]: unrecognized selector sent to instance 0x461d290

I have tried to use

[ViewControllerA performSelector:@selector(setAnnoSelected) withObject: nil afterDelay: 0.0];

But so far no joy.

Any ideas would be greatly appreciated.

Thanks
Cheryl

P.S. This is a great site for help - thanks to anyone who has ever answered a question as you have helped me too.
coconnor is offline   Reply With Quote
Old 03-09-2010, 04:14 PM   #2 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 49
Default

Quote:
Originally Posted by coconnor View Post
Hi

My iPhone app is made of of a main tabController with 4 main tabs. I have a situation where ViewController A loads ViewController B (using pushViewController). I now need to get back to ViewController A and and trigger an action on A from B.

Getting back to A is easy all I have to do is :-

self.tabBarController.selectedIndex = 0;
[self.navigationController popViewControllerAnimated:YES];

this then causes the ViewController A to be visible.

But how do I then get ViewController B to fire an action on A?

I have tried to use:-

ViewControllerA *aVC = ((ViewControllerA *)((UIViewController *)[self.tabBarC.tabBarController.viewControllers objectAtIndex:0]));
[aVC setAnnoSelected];

Only when I do that I get:-

-[UINavigationController setAnnoSelected]: unrecognized selector sent to instance 0x461d290

I have tried to use

[ViewControllerA performSelector:@selector(setAnnoSelected) withObject: nil afterDelay: 0.0];

But so far no joy.

Any ideas would be greatly appreciated.

Thanks
Cheryl

P.S. This is a great site for help - thanks to anyone who has ever answered a question as you have helped me too.
I'm trying to do the exact same thing: http://www.iphonedevsdk.com/forum/ip...d-subview.html

So far, no luck...
Journer is offline   Reply With Quote
Old 03-09-2010, 04:43 PM   #3 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 6
Default

For anyone curious I got it working by doing:-

Code:
UINavigationController   *navController = (UINavigationController *) [self.tabBarController.viewControllers objectAtIndex: 0];
ViewControllerA          *controller = [navController.viewControllers objectAtIndex: 0];

[controller setAnnoSelected];
Someone named Ben (Thanks Ben) helped me on UIViews firing an action in another UIViewController - Stack Overflow.

Thanks
Cheryl
coconnor is offline   Reply With Quote
Reply

Bookmarks

Tags
cocoa, iphone, obj c, xcode

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 271
18 members and 253 guests
14DEV, ADY, ArtieFufkin10, Dani77, HemiMG, IphoneSdk, jakerocheleau, JasonR, jimbo, MACralik, NSeven, prchn4christ, Rudy, silverwiz, spiderguy84
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:56 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0