我无法弄清楚如何以编程方式将视图添加到布局或页面中.
我需要在运行时添加视图而不使用静态xml声明,因为我需要从http请求对象中获取它们.... 我没有在文档中找到有用的信息.
谁知道该怎么办?
我正在使用TypeScript中的NativeScript入门教程:http: //developer.telerik.com/featured/getting-started-nativescript/
在一段代码中,我看到:
exports.loadSignUpView = function(args) {
    page = args.object;
    page.bindingContext = journeyInfo;
}
经过一些研究,我能够输入args作为
import app = require("application");
exports.loadSignUpView = function(args: app.ApplicationEventData) {
     //...
}
但这仍然无法帮助我键入上面的页面对象,它具有bindingContext属性.什么是与页面对应的TypeScript类型?
我正在构建一个照片浏览器应用程序,用户应在其中浏览页面以查看不同的照片。这是目前对我有用的视图。
<ScrollView orientation="horizontal" ios.pagingEnabled="true" >
  <StackLayout orientation="horizontal">
    <Image *ngFor="#picture of buffer" [src]="picture.originUrl" stretch="aspectFit"></Image>
  </StackLayout>
</ScrollView>
当我尝试应用叠加层时,问题就来了。因此,我尝试将整个包装成一个包,AbsoluteLayout以便可以ScrollView正常进行操作,但将覆盖层放在顶部。当我这样做时,滚动会完全中断。这是中断滚动的视图:
<AbsoluteLayout>
  <Label text="overlay" left="0" tope="0"></Label>
  <ScrollView orientation="horizontal" ios.pagingEnabled="true" left="0" top="0">
    <StackLayout orientation="horizontal">
      <Image *ngFor="#picture of buffer" [src]="picture.originUrl" stretch="aspectFit"></Image>
    </StackLayout>
  </ScrollView>
</AbsoluteLayout>
布局似乎可以正常工作,但是滚动会中断。有人对如何实现这一目标有任何想法吗?
我希望能够只需将View组件(插件)到通过代码的页面,并让它出现在一些X\Y中的网页...但我有点难倒.
任何通过page.content添加的尝试都会将其添加到layout\render pass中,因此占用空间.
所以这会在"任何"时间被注入"任意"页面,我无法控制将要使用的标记(知道我的意思吗?)没有XML,不幸的是答案不能只是将所有内容都包装在AbsoluteLayout中,因为无法对用户的app\layouts强制要求.
想法,甚至可能吗?
所以几天我开始这个应用程序 - 手表工作得很好,直到今天.
这就是我所说的: tns run android --emulator --device=ANDROID --watch
但是当我更改代码时,没有任何反应,我的更改不存在.当我运行tns医生时,它显示除了ios模拟器之外一切都是最新的(我现在不使用).
刚尝试重新安装应用程序(来自git - https://github.com/nestor94/my-instagram)并重新创建了avd.仍然 - 手表不工作.
谢谢!
我正在使用NativeScript创建一个示例应用程序.我在Android设备中运行应用程序时遇到模板解析错误.
我在模板中的代码只是:
<Page xmlns="http://schemas.nativescript.org/tns.xsd">
  <Page.actionBar>
      <ActionBar title="My ActionBar"/>
  </Page.actionBar>
</Page>
我收到以下错误:
Template parse errors:
Only void and foreign elements can be self closed "ActionBar" ("<Page xmlns="http://schemas.nativescript.org/tns.xsd">
  <Page.actionBar>
      [ERROR ->]<ActionBar title="My ActionBar"/>
  </Page.actionBar>
</Page>"): AppComponent@2:6
Error: Template parse errors:
Only void and foreign elements can be self closed "ActionBar" ("<Page xmlns="http://schemas.nativescript.org/tns.xsd">
  <Page.actionBar>
      [ERROR ->]<ActionBar title="My ActionBar"/>
  </Page.actionBar>
</Page>"): AppComponent@2:6
    at DirectiveNormalizer.normalizeLoadedTemplate (/data/data/org.nativescript.neurix/files/app/tns_modules/@angular/compiler/bundles/compiler.umd.js:13506:21)
    at /data/data/org.nativescript.neurix/files/app/tns_modules/@angular/compiler/bundles/compiler.umd.js:13499:53
    at ZoneDelegate.invoke (/data/data/org.nativescript.neurix/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:190:28)
    at Zone.run (/data/data/org.nativescript.neurix/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:83:43)
    at /data/data/org.nativescript.neurix/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:449:57
    at ZoneDelegate.invokeTask (/data/data/org.nativescript.neurix/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:223:37)
    at Zone.runTask (/data/data/org.nativescript.neurix/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:123:47)
    at drainMicroTaskQueue (/data/data/org.nativescript.neurix/files/app/tns_modules/nativescript-angular/zone.js/dist/zone-nativescript.js:355:35) …尝试在NativeScript视图中输出以下内容
<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="loaded">
    <StackLayout>
        <Label class="h1 c-grey" text="(re)volution" />
        <TextField class="c-bg-grey" id="email" text="{{ email }}" hint="Email Address" keyboardType="email" autocorrect="false" autocapitalizationType="none" />
        <TextField secure="true" text="{{ password }}" hint="Password" />
        <Button text="Sign in" class="btn btn-primary" tap="signIn" />
    </StackLayout>
    <GridLayout columns="50, auto, *" rows="50, auto, *" width="210" height="210" style.backgroundColor="lightgray">
        <Label text="Label 1" row="0" col="0" backgroundColor="red" />
        <Label text="Label 2" row="0" col="1" colSpan="2" backgroundColor="green" />
        <Label text="Label 3" row="1" col="0" rowSpan="2" backgroundColor="blue" />
        <Label text="Label 4" row="1" col="1" backgroundColor="yellow" />
        <Label text="Label 5" …我尝试使用NativeScript和Google maps API包创建带有自定义图标的标记.我将我的图标添加到了android资源中,然后构建了我的项目几次.
   var marker = new mapsModule.Marker();
   marker.position = mapsModule.Position.positionFromLatLng(result.latitude, result.longitude);
   marker.title = "Home";
   var icon = new Image();
   icon.imageSource = imageSource.fromResource('bot_marker');
   marker.icon = icon;
   marker.snippet = "This is where I live";
   marker.userData = { index: 1 };
   mapView.addMarker(marker);
即使我尝试icon或logo用于资源,它也不会出现.
到目前为止,我一直在AndroidManifest.xml文件中为应用添加必要的权限,如下所示
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.SEND_SMS" />
正如我在网上看到的那样.对于API 23及更高版本,应用程序需要在需要时动态询问权限.
所以我的问题是,我是否仍然需要在AndroidManifest.xml文件中添加权限,或者只是动态处理它或者我必须做两者.
-谢谢
您好我是移动开发和Angular 2的新手.我正在尝试请求阅读联系人的权限,但是NativeScript无法识别"android".
例如,我无法运行以下代码:
permissions.requestPermission(android.Manifest.permission.INTERNET, "I need these permissions because I'm cool");
Error: Cannot find name 'android'.
任何帮助将不胜感激.
android android-permissions nativescript angular2-nativescript angular
nativescript ×10
android ×2
angular ×2
ios ×2
layout ×2
typescript ×2
google-maps ×1
javascript ×1
mobile ×1
plugins ×1
tns ×1