我有一个应用程序,其中包含加载各种从本地HTML文件加载的UIWebView的菜单。 (此代码是在WebViewController)将NSDate传递给iOS中的本地UIWebView - Objective C
//Code for the WebView
vesperswebview.scrollView.bounces = NO;
[[vesperswebview scrollView] setBounces:NO];
[(UIScrollView*)[vesperswebview.subviews objectAtIndex:0] setShowsVerticalScrollIndicator:NO];
NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"data/html"];
NSURL *url = [NSURL fileURLWithPath:path];
NSString *theAbsoluteURLString = [url absoluteString];
NSString *queryString = @"#?manifest=Psalmody-Morning";
NSString *absoluteURLwithQueryString = [theAbsoluteURLString stringByAppendingString:queryString];
NSURL *finalURL = [NSURL URLWithString:absoluteURLwithQueryString];
NSURLRequest *request = [NSURLRequest requestWithURL:finalURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:(NSTimeInterval)10.0];
[vesperswebview loadRequest:request];
我也有叫FlatDate器中选择一种自定义的日期选择器:(此代码是在我的主视图控制器),它连接到一个进口FlatDatePicker开源项目我从GitHub获得。
- (void)flatDatePicker:(FlatDatePicker*)datePicker dateDidChange:(NSDate*)date {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSCalendar *coptic = [[NSCalendar alloc] initWithCalendarIdentifier:@"coptic"];
[dateFormatter setCalendar:coptic];
[dateFormatter setDateStyle:NSDateFormatterLongStyle];
if (datePicker.datePickerMode == FlatDatePickerModeDate) {
[dateFormatter setDateFormat:@"EEEE, MMMM, dd, yyyy"];
} else if (datePicker.datePickerMode == FlatDatePickerModeDate) {
[dateFormatter setDateFormat:@"HH:mm:ss"];
} else {
[dateFormatter setDateFormat:@"EEEE, MMMM, dd, yyyy HH:mm:ss"];
}
NSString *value = [dateFormatter stringFromDate:date];
self.labelDateSelected.text = value;
}
我的问题是,当我选择在我的主视图控制器的日期,如何可以在上述日期被保存并传递到下一个视图加载相应的JavaScript是在我的数据库日期敏感 ?
有这么多的方式来实现这一目标。 1)在WebViewController中定义一个变量dateString,并在用户选择日期并推送WebViewController时进行设置。 2)如果你总是显示两个ViewController,那么一旦用户点击DatePicker,就使用委托模式更新WebViewController。 https://developer.apple.com/library/content/documentation/General/Conceptual/CocoaEncyclopedia/DelegatesandDataSources/DelegatesandDataSources.html。 –
我已阅读多次链接的文档,并且我已经有几个月的这个问题了,请介意直接提供代码。你会让我的生活大声笑 –
然后,我需要更多的信息,你的实施是什么。就像我说的我有几个假设你如何显示你的WebViewController,你是否允许用户先选择日期。然后你推动WebViewController并显示HTML。 –