I think that is what I did with the line 

[viewController2.label2 setText:label1.text];

Then [self.view addSubView:viewController2.view]; brings up the subview.

The only problem is that the text in label two is not displayed correctly until 
I release and reload the view.  I have a button to remove view which fires the 
code [self.view removefromSuperview];  then when i bring the view back up with 
the above code, the label has the correct text in it.

This seems to be something pretty simple and yet I am struggling with it.  What 
is a good resource for me to read that can give me a basic understanding of 
things like this?  Why do I have to bring this view up twice in order to see 
the proper text in the label?

Steve






On Sep 21, 2010, at Sep 21:4:11 PM, Eric E. Dolecki wrote:

> You could make a public method in the second and call that from the first to 
> set the text too I suppose.
> 
> 
>   Google Voice: (508) 656-0622
>   Twitter: eric_dolecki      XBoxLive: edolecki      PSN: eric_dolecki
>   http://blog.ericd.net
> 
> 
> 
> On Tue, Sep 21, 2010 at 5:03 PM, Steve Wetzel <stevewet...@mac.com> wrote:
> Thanks Everyone.
> 
> I could not get the
> 
> [self.viewController1.label2.text
> 
> or the
> 
> [self view addSubview:viewController2.view];
> 
> to work for some reason.  Then it dawned on me that I could set the value 
> right before I added the Subview!
> 
> [viewController2.label2 setText:label1.text];
> [self.view addSubview:viewController2.view];
> 
> This works, although for some reason the label does not update unless I 
> reload the view.  I will figure out what is going on there.
> 
> Thanks for the suggestions.
> 
> Steve
> 
> 
> 
> 
> 
> 
> On Sep 21, 2010, at Sep 21:3:25 PM, Conrad Shultz wrote:
> 
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > On 9/21/10 11:57 AM, Steve Wetzel wrote:
> >> How do I access and object on one view from another view?  I cannot
> >> figure it out.
> >>
> >> I have two view controllers and two views.  Lets call them
> >> viewController1 and viewController2 and view1 and view2.
> >> ViewController1 loads the second view by:
> >>
> >> [self.view addSubview:viewController2.view];
> >>
> >> There is a label in view1 that I want to get the value of the text
> >> from in the code for viewController2.  How do I do this?
> >
> > Caveat: you ought to listen to Quincey's advice, since it will give a
> > more robust, or at least a cleaner, implementation.
> >
> > That said, for the specific situation at hand, UIView has a superview
> > property that returns a reference to, well, the view's superview (if it
> > exists).  If you have the label as a property of view1 ("theLabel"), you
> > could do something like the following (in viewController2):
> >
> > UILabel *theLabel = [[[self view] superview] theLabel];
> >
> > If it's a tagged view, you could do something like:
> >
> > NSInteger labelTag = (whatever you set, probably in IB);
> > UILabel *theLabel = [[[self view] superview] viewWithTag:labelTag];
> >
> > (Since properties are involved, you are of course free to use dot syntax
> > in many places above if that's your preference.)
> >
> > - --
> > Conrad Shultz
> >
> > Synthetiq Solutions
> > www.synthetiqsolutions.com
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.7 (Darwin)
> > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> >
> > iD8DBQFMmRSvaOlrz5+0JdURApMYAJ0aAv996lOHMDyY5oTKg0ju0LIbIACePwij
> > i3EBvDqS2WGzo+wnrBT9Mz8=
> > =Ea2B
> > -----END PGP SIGNATURE-----
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/edolecki%40gmail.com
> 
> This email sent to edole...@gmail.com
> 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to