Sunday, 15 September 2013

objective c - Set textField.text from other class of my app -



objective c - Set textField.text from other class of my app -

i trying solve problem searching in developer library dont know should search.

i have headviewcontroller.h set property of iboutlet textfield. in view have view (containerview) containerviewcontroller class.

my problem cant set textfield text in headviewcontroller if seek set property of headviewcontroller class in containerviewcontroller.h

here trying to:

containerviewcontroller.h

@class headviewcontroller; @property headviewcontroller *hvc;

containerviewcontroller.m

#import "headviewcontroller.h" // in ibaction method self.hvc.textfield.text = @"text container view";

i trying utilize [textfield settext:@""] , [textfield insertext:@""] same result. if know problem or have search in developer library appreciate that.

you need set value of property, hvc. hvc pointer, declaring doesn't create point anything, says class of object should point to. since containerviewcontroller embedded in container in headviewcontroller's view, makes headviewcontroller parent. can reference headviewcontroller containerviewcontroller using self.parentviewcontroller.

// in ibaction method self.hvc = (headviewcontroller *)self.parentviewcontroller; self.hvc.textfield.text = @"text container view";

objective-c xcode uitextfield

No comments:

Post a Comment