我启动了我的 cellForRowAtIndexPath。它出现了,但是当我尝试从不同的类中引用它时,它返回(null)
. 如果我在 viewDidLoad 中启动它,它可以工作,但它需要在 UITableView 中。
添加相册视图控制器:
// .h
IBOutlet UISwitch *privateSwitch;
@property (nonatomic, retain) IBOutlet UISwitch *privateSwitch;
// .m
@synthesize privateSwitch;
privateSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(199, 8, 0, 0)];
[privateSwitch addTarget:self action:@selector(switchToggled:) forControlEvents: UIControlEventTouchUpInside];
[cell.contentView addSubview:privateSwitch];
第二视图控制器:
// .m
TableViewAppDelegate *dataCeter = (TableViewAppDelegate *)[[UIApplication sharedApplication] delegate];
AddAlbumViewController *addAlbumViewController = [[AddAlbumViewController alloc] initWithNibName:@"AddAlbum" bundle:[NSBundle mainBundle]];
UIView *tempView = addAlbumViewController.view;
NSLog(@"privateSwitch: %@", addAlbumViewController.privateSwitch);
请帮忙谢谢。