我正在关注NativeScript教程,但是当我尝试使用res://加载图像时,我无法使用iOS.
<Image src="res://logo" stretch ="none" />
Run Code Online (Sandbox Code Playgroud)
该文件位于App_Resources/iOS/logo.png中
更新:
现在有效:
1.-从设备/模拟器中卸载应用程序
2.-然后做一个新的tns build ios以获得新的构建
我正在尝试使用routerExtensions中的页面转换的页面转换但没有成功。(2.3.0)
我在js中尝试过:
this.routerExtensions.navigate(
[
'myPage'
],
{
animated: true,
transition:
{
name: 'flip',
duration: 2000,
curve: 'linear'
}
}
);
Run Code Online (Sandbox Code Playgroud)
我在 xml 中尝试过:
<Button text="Goto myPage" [nsRouterLink]="['/myPage']" pageTransition="flip"></Button>
Run Code Online (Sandbox Code Playgroud)
当我导航到“myPage”但没有动画时,这两种方法都有效。我是否需要更改设置才能“启用”动画,或者我是否遗漏了一些明显的东西?
嗨,我的模板如下所示
<ListView [items]="modules">
<template let-item="item" >
<StackLayout orientation="vertical">
<Switch (checkedChange)="onSwitchModule(item.id,$event)" [checked]="item.active"></Switch>
</StackLayout>
</template>
</ListView>
Run Code Online (Sandbox Code Playgroud)
我的控制器是
ngOnInit() {
this._moduleService.getUserModules()
.subscribe(
response=>{
this.modules = response.data;
}
)
}
onSwitchModule(itemId) {
console.log(itemID); //Gets called on initial true binding on switch checked
}
Run Code Online (Sandbox Code Playgroud)
每次页面加载时 onSwitchModule 都会被调用,item.active 在任何项目上为 true,如何处理?
注意:Nativescript 初学者
我正在使用Nativescript/Angular 2构建应用程序
我希望能够从 URL 下载文件并将其保存到设备中普通用户可以轻松找到它的位置。我相信,下载将是这两个最好的地方iOS和Android。如果我错了,请纠正我。
该文件可以是任何文件类型,而不仅仅是图像。所以主要是spreadsheet,word document,pdf,png,jpg,等。
我在网上和文档中搜索过。该文档描述了一种名为getFile的方法,该方法获取文件并将其保存到您的设备。
我在我的代码中实现了这一点,如下所示:
download (id) {
console.log('Download Started');
getFile("https://raw.githubusercontent.com/NativeScript/NativeScript/master/apps/tests/logo.png").then(function (r) {
console.log(r.path);
}, function (e) {
//// Argument (e) is Error!
});
}
Run Code Online (Sandbox Code Playgroud)
这样做的问题是它将它保存到非用户可访问的位置,例如:
/data/user/0/com.myapp.example/files/logo.png
Run Code Online (Sandbox Code Playgroud)
更新:
我也试过直接指定路径:
fs.knownFolders.documents();
Run Code Online (Sandbox Code Playgroud)
但是,此方法获取用户或外部应用程序无法访问的当前应用程序的文档文件夹
TNS v2.5.0
我已经导入LISTVIEW_DIRECTIVES了我的app.module,我的模板看起来像
<ActionBar title="Events"></ActionBar>
<StackLayout orientation="vertical">
<RadListView [items]="events">
<template tkListItemTemplate let-event="item">
<StackLayout orientation="vertical">
<Image [src]="'https:' + event.image" stretch="aspectFit"></Image>
<Label [nsRouterLink]="['/event', event.id]" [text]="event.title"></Label>
</StackLayout>
</template>
</RadListView>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)
但这只显示为常规ListView可以正常显示。
另外,如果我尝试一个GridLayout喜欢
<ActionBar title="Events"></ActionBar>
<GridLayout>
<RadListView [items]="events">
<template tkListItemTemplate let-event="item">
<StackLayout orientation="vertical">
<Image [src]="'https:' + event.image" stretch="aspectFit"></Image>
<Label [nsRouterLink]="['/event', event.id]" [text]="event.title"></Label>
</StackLayout>
</template>
</RadListView>
</GridLayout>
Run Code Online (Sandbox Code Playgroud)
该应用程序崩溃并显示错误消息
file:///app/tns_modules/nativescript-telerik-ui/listview/listview.js:1034:104:JS错误TypeError:未定义不是一个对象(正在评估'itemViewDimensions.measuredWidth')2月5日11:40:53 Marcuss -iMac com.apple.CoreSimulator.SimDevice.1A8C1E25-DAC0-4BA0-822E-5A6F731F1CD7.launchd_sim [31919](UIKitApplication:org.nativescript.t4g [0x7b2a] [36194]):由于分段错误而退出了服务:11
不知道我是否错过了某个地方的导入,但是文档非常粗略,因此很难确定并查看示例
listview nativescript angular2-nativescript nativescript-telerik-ui
我使用此代码上传图像:https: //github.com/NativeScript/sample-ImageUpload
当我上传图像时,我收到了成功通知.我正在尝试从服务器读取响应并检查任务的完整事件:
task.on("complete", logEvent);
function logEvent(e) {
console.log(JSON.stringify(e));
}
Run Code Online (Sandbox Code Playgroud)
这是输出:
{"eventName":"complete","object":{"_observers":{"complete":[{}],"propertyChange":[{}]},"_session":{"_id":"image-upload"},"_id":"image-upload{1}","_description":"{ 'uploading': Test0.png }","_upload":3807297,"_totalUpload":3807297,"_status":"complete"},"response":{}}
Run Code Online (Sandbox Code Playgroud)
如你所见,响应为空.那么如何从服务器读取响应?
我正在做一个 Nativescript-Angular-App,但遇到了问题。
用户必须单击图片上的正确位置。
我不明白如何获取简单点击的坐标。
我可以通过触摸手势(TouchGestureEventData)获取坐标,但它提供了信息流。我只想要一个数据。
我尝试过触摸:
public onTouch(args: TouchGestureEventData) {
console.log(args.getActivePointers()[0].getX());
}
Run Code Online (Sandbox Code Playgroud)
但我得到了太多的数据(每个动作)。
有没有一种方法可以通过简单的点击来获取坐标?
谢谢!
运行tns platform add android命令时出现错误。
我可以运行其他应用程序(新应用程序),但没有我的当前应用程序,并且在我安装codeworks_android它后,所有发生的事情都会更改 SDK 的路径,然后我重新安装本机脚本,但我无法添加 Android 平台。
error ENOENT: no such file or directory, scandir 'PATH_PORJECT\platforms\android\app\src\main\res'
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用 new 将 Angular 应用程序迁移到带有 Nativescript 的共享代码库@nativescript/schematics,但是,在构建应用程序的移动版本时,我在导入我的 Angular 库时遇到了问题。我使用 angular-cli 创建了库 ( ng generate library)。
对于 web 版本,我所要做的就是单独构建库ng build library-name,然后允许我将它导入到主应用程序中。
如何构建可以在运行时导入主应用程序的库的移动版本tns run ios --bundle?我已经使用适当的 *.tns 文件迁移了库的组件和模块。
任何帮助表示赞赏
我有一个 OpenEdge 数据库,我创建了一个 REST 服务,并且能够从外部世界对它进行 CRUD。我创建了一个可以从 REST 服务等中提取数据的 Nativescript 应用程序,但现在我想要推送通知。
我知道 Progress Kinvey 后端和具有推送通知功能的 Firebase 后端,但我不想使用它们。
有没有办法在我的 REST 服务器等上创建我自己的推送通知?
rest openedge push-notification nativescript angular2-nativescript