MyViewController has one UIButton and another MainViewController use MyViewController.
but MainViewController can't change UIButton title in MyViewController.
also, in MyViewController only change UIButton title in viewDidLoad method.
What's wrong?
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;
}
}