伙计们,这已经让我头疼了好几个小时了.... :(
我有一组控制器,它们被加载到滚动视图中
我想将值分配给标签“类别”,但我无法执行此操作 - 值显示为 NULL ??
但是,我可以在 viewDidLoad 方法中对其进行硬编码?
我尝试了几种方法,但都没有奏效?...
我的 .h 文件看起来像这样......
@interface ReviewCategoryViewController : UIViewController {
@public
UILabel *CategoryTitle;
}
- (id)initWithCategory:(NSString *)category;
- (id)setCategory:(NSString *)category;
@property (strong, nonatomic) IBOutlet UILabel *CategoryTitle;
@end
我的实现看起来像这样......
- (id)setCategory:(NSString *)category
{
[self.CategoryTitle setText:category];
NSLog(@">>2. Category %@ %@", category, CategoryTitle.text);
return self;
}
// load the view nib and initialize the pageNumber ivar
- (id)initWithCategory:(NSString *)category
{
self = [super initWithNibName:@"ReviewCategoryViewController" bundle:nil];
[self.CategoryTitle setText:category];
NSLog(@">>1. Category %@ %@", category, CategoryTitle.text);
return self;
}
我对该方法的调用如下所示...
ReviewCategoryViewController *controller = [viewControllers objectAtIndex:cardNo];
if ((NSNull *)controller == [NSNull null])
{
NSString *temp = [categories_array objectAtIndex:cardNo];
controller = [[ReviewCategoryViewController alloc] initWithCategory:temp];
[controller setCategory:temp];
[viewControllers replaceObjectAtIndex:cardNo withObject:controller];
}
我的日志显示以下内容????
2013-04-12 16:54:27.507 Review Writer[14455:11603] >>1. Category Adapability **(null)**
2013-04-12 16:54:27.509 Review Writer[14455:11603] >>2. Category Adapability **(null)**