在 UIViewController 的 viewDidLoad 方法中,我这样做:
UIButton *b = [[UIButton buttonWithType:UIButtonTypeRoundedRect]
initWithFrame:CGRectMake(0, 0, 100, 100)];
[b setTitle:@"Testing" forState:UIControlStateNormal];
[b setTitleColor: [UIColor blackColor] forState: UIControlStateNormal];
[self.view addSubview:b]; // EDIT: should be 'b'
NSLog(@"button title: %@", [b titleLabel].text);
按钮显示,但标题不显示。NSLog 行将“Testing”打印到控制台。关于我做错了什么有什么建议吗?