喜的朋友,我必須讓時間申請 細胞迄今爲止我已經摸索tableview.i有一個部分和兩個排 當我的應用程序開始我顯示的第一個細胞都在默認的日期電池我顯示今天白天+ 1和nextcell我今天顯示當天+ 6他們我可以看到,但如何調用從datepickerview選擇了iphone
- (id)init
{
[super initWithStyle:UITableViewStyleGrouped];
NSDate *todaysDate = [NSDate date];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
[dateComponents setDay:1];
app.selectionData.fromDateSelected = [gregorian dateByAddingComponents:dateComponents toDate:todaysDate options:0];
[dateComponents release];
[gregorian release];
//this is for 6day
NSDate *todaysDate1 = [NSDate date];
NSCalendar *gregorian1 = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *dateComponents1 = [[NSDateComponents alloc] init];
[dateComponents1 setDay:6];
app.selectionData.toDateSelected = [gregorian1 dateByAddingComponents:dateComponents1 toDate:todaysDate1 options:0];
[dateComponents1 release];
[gregorian1 release];
return self;
}
,但知道我想如果
第一個單元格選定的日期是從日期pickerview和第二小區變更日期小於第一個單元格選擇日期,然後將第二個單元格日期自動更改爲第一個單元格選定日期+ 5請幫助我如何解決我t什麼是我的代碼我必須做的改變我是默認顯示這一次在這個這是我的代碼在運行時間 這段代碼我writemin我的firstview控制器類在哪裏我顯示這個日期當我的應用程序啓動 在tableviewcellrowAtindexpath
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd/MM/yyyy"];
NSString*fromDate = [dateFormat stringFromDate:app.selectionData.fromDateSelected];
// NSString *toDate = [dateFormat stringFromDate:targetDate1];
NSString *toDate = [dateFormat stringFromDate:app.selectionData.toDateSelected];
if ([indexPath row] == 0 && [indexPath section] == 1)
{
[email protected]"From Date";
cell.detailTextLabel.text=fromDate;
NSLog(@"this is for fromDate:%@",fromDate);
}
if ([indexPath row] == 1 && [indexPath section] == 1)
{
[email protected]"To Date";
cell.detailTextLabel.text=toDate;
}
[dateFormat release];
dateFormat = nil;
this is code od dateview where i put my datepicker from here i selected date
- (void)viewDidLoad
{
// if(datePicker != nil && [datePicker retainCount] > 0)
// {
// [datePicker release];
//
// datePicker = nil;
//}
datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 40, 0, 0)];
[datePicker addTarget:self action:@selector(DateChangeForFinalPayMent) forControlEvents:UIControlEventValueChanged];
datePicker.datePickerMode = UIDatePickerModeDate;
datePicker.date = [NSDate date];
datePicker.minimumDate = [NSDate date];
[self.view addSubview:datePicker];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
-(void)DateChangeForFinalPayMent{
if ([selectionData type] == 0)
[selectionData setFromDateSelected:[datePicker date]];
else
[selectionData setToDateSelected:[datePicker date]];
// [super viewWillDisappear:animated];
}
你的問題不明確。你想實現什麼 – Anand
@Anand我想實現第一個單元格選擇日期從日期選擇器視圖改變,第二個單元格日期小於第一個單元格選擇日期,然後將第二個單元格日期自動更改爲第一個單元格選定日期+ 5 – Rocky
好的,我開始知道,當你選擇第一個單元格時,你想更新單元格右邊的日期。等待幾分鐘,我將發佈代碼 – Anand