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 > iPhone SDK Development Forums > iPhone SDK Development > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 11-17-2011, 09:18 PM   #1 (permalink)
Registered Member
 
Join Date: Oct 2011
Posts: 3
priyahari is on a distinguished road
Default Calling a method from subview without a button action event

Hi,

I have a RootViewController(UINavigationController) and inside this I am trying to programmatically create a UIViewController with few text fields. This UIViewController is created and pushed in when a button is clicked.

I need a method to be called when this UIViewController appears. I cannot use viewdidload or viewwillappear since it all points to rootviewcontroller. Is there any other way to do this without any button click on UIViewController?


Thanks!
priyahari is offline   Reply With Quote
Old 11-23-2011, 04:07 AM   #2 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 28
Mogglas is on a distinguished road
Default

Quote:
Originally Posted by priyahari View Post
Hi,

I have a RootViewController(UINavigationController) and inside this I am trying to programmatically create a UIViewController with few text fields. This UIViewController is created and pushed in when a button is clicked.

I need a method to be called when this UIViewController appears. I cannot use viewdidload or viewwillappear since it all points to rootviewcontroller. Is there any other way to do this without any button click on UIViewController?


Thanks!
Check out NSNotificationCenter, with that, you can send messages and listen to them from anywhere in your app.
Mogglas is offline   Reply With Quote
Old 11-23-2011, 05:23 AM   #3 (permalink)
Registered Member
 
Join Date: Nov 2009
Location: Helsinki
Posts: 304
fiftysixty is on a distinguished road
Default

Quote:
Originally Posted by priyahari View Post
Hi,

I have a RootViewController(UINavigationController) and inside this I am trying to programmatically create a UIViewController with few text fields. This UIViewController is created and pushed in when a button is clicked.

I need a method to be called when this UIViewController appears. I cannot use viewdidload or viewwillappear since it all points to rootviewcontroller. Is there any other way to do this without any button click on UIViewController?


Thanks!
If you subclass your UIViewController, then you should have no problems with viewDidLoad or any other view controller life cycle methods.
fiftysixty is offline   Reply With Quote
Old 12-22-2011, 08:51 AM   #4 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,002
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by priyahari View Post
Hi,

I have a RootViewController(UINavigationController) and inside this I am trying to programmatically create a UIViewController with few text fields. This UIViewController is created and pushed in when a button is clicked.

I need a method to be called when this UIViewController appears. I cannot use viewdidload or viewwillappear since it all points to rootviewcontroller. Is there any other way to do this without any button click on UIViewController?


Thanks!

You said "I cannot use viewdidload or viewwillappear since it all points to rootviewcontroller."

That doesn't make any sense. Each view controller is it's own entity, with it's own methods.

When your navigation controller pushes a new view controller, that new view controller;s different methods get called. It will get an initWithNibName, then a viewDidLoad call, then a viewWillAppear, and finally, once the view controller's views are on-screen, it will get a viewDidAppear message. There are no doubt more methods that get called - I'm summarizing.

If you want your new view controller to notify the parent view controller once it's on-screen, add code to the child view controller's viewDidAppear method that sends a message to the parent view controller. Done.

EDIT: It's pretty clear from your questions that you are just starting to figure out how to use navigation controllers and view controllers. This is a "how do I add 1+1" question, and does not belong in the advanced discussion forum.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.

Last edited by Duncan C; 12-22-2011 at 08:56 AM.
Duncan C is offline   Reply With Quote
Old 12-22-2011, 08:53 AM   #5 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,002
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by Mogglas View Post
Check out NSNotificationCenter, with that, you can send messages and listen to them from anywhere in your app.
No need for that. As I and the other poster have said, you just need to make the new view controller a custom subclass of UIViewController and implement the viewDidAppear: method.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Reply

Bookmarks

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: 403
12 members and 391 guests
bignoggins, djqbert, epaga, flamingliquid, jcdevelopments, leighec68, LunarMoon, markolo, omagod, pinacate, revg, taylor202
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,645
Threads: 94,111
Posts: 402,861
Top Poster: BrianSlick (7,990)
Welcome to our newest member, leighec68
Powered by vBadvanced CMPS v3.1.0

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