MyViewController में एक UIButton और एक अन्य MainViewController MyViewController का उपयोग करें।UIButton शीर्षक कैसे बदलें?
लेकिन मेनव्यू कंट्रोलर MyViewController में UIButton शीर्षक नहीं बदल सकता है।
भी, MyViewController में केवल UIButton शीर्षक कोडिडलोड विधि में बदलें।
क्या गलत है?
MyViewController
@interface MyViewcontroller : UIViewController {
IBOutlet UIButton *imageButton;
}
@property (nonatomic, retain) UIButton *imageButton;
@implementation MyViewcontroller : UIViewController {
@synthesize imageButton;
- (void)viewDidLoad { // can change button title
[imageButton setTitle:@"buttonTitle" forState:UIControlStateNormal]
}
- (void)setButtonTitle { // can't change button title
[imageButton setTitle:@"buttonTitle" forState:UIControlStateNormal];
}
}
MainViewController
@implementation MainViewController : UIViewController {
@synthesize scrollView;
- (void)viewDidLoad { // can't change button title
MyViewcontroller *myView = [[MyViewcontroller alloc] initWithNibName:@"MyViewcontroller" bundle:nil];
[myView.imageButton setTitle:@"ddd" forState:UIControlStateNormal];
[scrollView addSubview:myView.view];
[myView release], myView = nil;
}
}
धन्यवाद। मैं आलसी लोडिंग सीखूंगा – seapy
मुझे उस बिट को याद आया - ऐसा लगता है कि मेरे पास +1 – BoltClock
सीखने के लिए बहुत कुछ है, मैं अपने बटन पर टेक्स्ट सेट करने में परेशानी में भाग गया क्योंकि मैं 'setBackgroundImage' के बजाय 'setImage' का उपयोग कर रहा था। यदि आप 'setImage' का उपयोग करते हैं तो यह आपके टेक्स्ट को कवर करेगा। – zekel