0
我呈現視圖控制器是這樣的:如何在呈現爲presentModalViewController之前設置ViewController的屬性?
FBViewController *fbViewController =[[FBViewController alloc] initWithNibName:@"FBViewController" bundle:nil];
[email protected]"hello"; // I set the value of the property label which is the outlet
[self presentModalViewController:fbViewController animated:YES];
FBViewController.h:
#import <UIKit/UIKit.h>
@interface FBViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *label;
@end
FBViewController.m:
...
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"%@", self.label.text); // Here instead of "hello" i get the value which was in nib file.
}
...
的問題是如何設置標籤的值?
加載方法謝謝你的答案。你知道我的代碼爲什麼不起作用嗎?爲什麼我不能直接設置插座的屬性? – Alex 2012-03-26 08:21:09
因爲控件在模態視圖控制器上重新生成顯示和標籤文本集默認文本....! – Dinesh 2012-03-26 09:21:15