MyViewController имеет один UIButton, а другой MainViewController использует MyViewController.
но MainViewController не может изменить название UIButton в MyViewController.
также, в MyViewController только изменить название UIButton в методе viewDidLoad.
Что случилось?
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;
}
}