我已经使用了NativeScript datepicker,并且可以与Android应用程序正常工作,但是我在iOS中运行相同的应用程序,则该应用程序将崩溃。
下面给出了我使用的代码
private openDropDownSelectionModal<T>(dropDownType: string, selectButtonText = 'Select Item', data?: T): Promise<any> {
let modalDialogOptions: ModalDialogOptions = {
context: {
buttonText: selectButtonText,
data: data
},
viewContainerRef: this.viewContainerRef
};
let component: any = undefined;
switch (dropDownType) {
case 'date':
component = DatePickerModalComponent;
break;
case 'time':
component = TimePickerModalComponent;
break;
default:
component = DropDownModalComponent
}
return this.modalDialogService.showModal(component, modalDialogOptions);
}
并从此处调用此功能
public openDeadlineTimePickerSelectionModal() {
this.openDropDownSelectionModal('time', 'Select Deadline Time', { date: this.deadlineDate })
.then((selectedTime: Date) => {
if (selectedTime) {
this.deadlineDate.setHours(selectedTime.getHours());
this.deadlineDate.setMinutes(selectedTime.getMinutes());
this.deadlineDate.setSeconds(0);
const updatedTask = _.cloneDeep(this.task);
updatedTask.deadlineDate = this.deadlineDate;
this.saveTask(updatedTask);
}
});
}
错误:
答案 0 :(得分:2)
在本机脚本问题跟踪器上创建了两个类似的问题,here和here。
您可以访问这些链接以获取更多信息,此外,如果您使用的是ScrollView
,请尝试将其包装在StackLayout
中,如下所示:
@Component({
moduleId: module.id,
template: `
<StackLayout>
<ScrollView #datePickerModalView>
<StackLayout>
<DatePicker #datePicker verticalAlignment="center" (loaded)="configure(datePicker)"></DatePicker>
<Button class="btn btn-primary btn-active" [text]="buttonText" (tap)="selectDate(datePicker)"></Button>
<Button class="btn" text="Cancel" (tap)="cancel()"></Button>
</StackLayout>
</ScrollView>
</StackLayout>
`})