我想将 datepicker.date 从 DatePickerPopupViewController 传递给我的 SensorvViewcontroller,如下所示。但是,它返回我“null”。我究竟做错了什么?我的代码如下:
#import "DatePopoverViewController.h"
@interface DatePopoverViewController ()
@end
@implementation DatePopoverViewController
@synthesize datePicker;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
datePicker.date=[NSDate date];
}
@end
#import "SensorViewController.h"
@interface SensorViewController ()
@end
// this represent my button which triggers popupViewController
-(void)chooseDate
{
if([popoverController isPopoverVisible])
{
[popoverController dismissPopoverAnimated:YES];
}
else
{
CGRect popRect=CGRectMake (900,1,1,1);
//CGRect popRect=CGRectMake (tools.frame.origin.x,tools.frame.origin.y,50,50);
popoverController.popoverContentSize =CGSizeMake(320,216);
[popoverController presentPopoverFromRect:popRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
datepop=[[DatePopoverViewController alloc]init];
NSDate *ali= datepop.datePicker.date;
NSLog(@"%@",ali);
}
}
@end