cellForRowAtIndexPath を開始します。表示されますが、別のクラスから参照しようとすると、 が返されます(null)
。viewDidLoad で開始すると動作しますが、UITableView にある必要があります。
AddAlbumViewController:
// .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];
SecondViewController:
// .m
TableViewAppDelegate *dataCeter = (TableViewAppDelegate *)[[UIApplication sharedApplication] delegate];
AddAlbumViewController *addAlbumViewController = [[AddAlbumViewController alloc] initWithNibName:@"AddAlbum" bundle:[NSBundle mainBundle]];
UIView *tempView = addAlbumViewController.view;
NSLog(@"privateSwitch: %@", addAlbumViewController.privateSwitch);
助けてくださいありがとう。