标签: nativescript

触摸文本字段外后如何隐藏键盘?

我有一个跨平台的应用程序。我有一个包含多个 TextField 的表单。我想在用户触摸文本字段外部时隐藏键盘,因为它覆盖了发送数据的按钮。

我能怎么做?

在我的 .html 文件中,我有:

<ScrollView>
  <GridLayout ios:style="margin-top:50">
    <StackLayout class="form">

      <!-- Some TextView -->

    </StackLayout>
  </GridLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

编辑

这是一个显示错误的操场

android ios typescript nativescript angular

1
推荐指数
1
解决办法
1914
查看次数

Angular + Nativescript 代码共享项目移除操作栏

我的项目正在使用 Angular + Nativescript 代码共享项目为 Android 和 IOS 的 web 以及移动构建。

问题是试图删除整个应用程序的操作栏。我已经阅读了一些关于这个问题的帖子,但是似乎没有一个解决方案有效,或者至少最终不是一个很好的解决方案。

我试图添加<Page actionBarHidden="true"></page>但是这app.component在包含路由的其他组件中或在其他组件中根本不起作用,例如 a home.componentwith the route home。如:

<Page actionBarHidden="true">
  <StackLayout orientation="vertical">
    <Image src="res://buy" stretch="none" horizontalAlignment="center"></Image>
  </StackLayout>
</Page>
Run Code Online (Sandbox Code Playgroud)

我还尝试了一种专门针对 android 的方法,看看我是否可以通过AndroidManifest.xml文件解决这个问题,就像我通过更新 android 清单来删除操作栏来制作本机 Android 应用程序一样。对于健全性测试,我还尝试通过以下方式使用它styles.xml

<style name="AppThemeNoActionBar" parent="AppTheme">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>
Run Code Online (Sandbox Code Playgroud)

在这些失败的尝试之后,我尝试了其他人推荐的以下代码,Page例如:

import { Page } from 'tns-core-modules/ui/page';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {

  ngOnInit() {
    this.page.actionBarHidden …
Run Code Online (Sandbox Code Playgroud)

android-actionbar nativescript angular nativescript-codesharing angular-nativescript

1
推荐指数
1
解决办法
888
查看次数

iOS 上的 Nativescript localhost http 调用失败

我在 Windows 上使用 Nativescript sidekick cloud build 在 iOS 上测试我的应用程序 - 我还连接了我的 iPhone。

根据这篇文章,我正在向 localhost 发送我的 http 请求,但他们一直因这个错误而失败。

http://localhost:52553/api/rewards/all 的Http 失败响应:0 未知错误
错误:无法连接到服务器。

这是我对奖励服务的实现

import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";

import { Observable, of } from 'rxjs';
import { SimpleReward } from "../models/simple-reward";
import { take, catchError } from "rxjs/operators";

@Injectable()
export class RewardsService {

    private baseUrl = "http://localhost:52553/api/rewards";

    constructor(private http: HttpClient) { }

    getAllRewards(): Observable<SimpleReward[]> {
        const url = `${this.baseUrl}/all`; …
Run Code Online (Sandbox Code Playgroud)

nativescript angular

1
推荐指数
1
解决办法
1038
查看次数

如何在 NativeScript 中隐藏 ScrollView 的滚动条?

我一直在来回寻找如何从 html 文件而不是 typescript 或 JavaScript 中隐藏 NativeScript Angular 中 ScrollView 的滚动条,但我找不到它。

我已经尝试过什么:

  • 线程显示了一种通过访问本机 API 来实现的方法,但对于 iOS 和 Android 来说是不同的。我正在寻找跨平台解决方案。
  • 我已经使用了这个插件,但我又在寻找一种更简单的方法,比如某种属性<ScrollView>标签。

环境:

节点:10.16
npm:6.9.0
NativeScript:5.4.0

nativescript

1
推荐指数
1
解决办法
718
查看次数

如何从 IOS 上的列表视图中删除分隔线?

我在删除每个列表项后的分隔线时遇到问题,并且无法更改分隔线颜色。

我在 Listview 标签和 CSS 中尝试了 separatorColor="transparent" 属性,但它们都不起作用。我也尝试过 SeparatorVisibility="None" 属性,但没有运气。

我已经尝试过GitHub 提供的这个解决方案,但它不起作用。

这是代码:

<GridLayout row="1" class="shop-list-container">
    <ListView [items]="rewardsPageData?.shops" class="list-group"  height="{{rewardsPageData?.shops?.length * 75}}" separatorColor="transparent">
        <ng-template let-shop="item">
            <GridLayout class="shop-item list-group-item" columns="2*, 6*, 2*" rows="*, auto" (tap)="goToShopDetails(shop.id)">
                <Image src="{{shop.logoImageUrl}}" class="thumb img-circle" col="0" row="0" rowSpan="2" horizontalAlignment="left"></Image>
                <Label class="shop-name" [text]="shop.title" row="0" col="1"></Label>
                <Label class="shop-type" text="{{shop?.category}}" row="1" col="1"></Label>
                <Label text="See location" class="see-location-text" textWrap="true" col="2" row="0" rowSpan="2" horizontalAlignment="right"></Label>
            </GridLayout>
        </ng-template>
    </ListView>
</GridLayout>
Run Code Online (Sandbox Code Playgroud)

nativescript nativescript-angular

1
推荐指数
1
解决办法
1340
查看次数

{N} Nativescript 6 - TypeError:无法读取未定义的属性“ViewCompat”

从 NS 5 更新到 NS 6 后,尝试在 Android 上运行我的应用程序时出现以下错误:

[Vue warn]: Error in v-on handler: "TypeError: Cannot read property 'ViewCompat' of undefined"
Run Code Online (Sandbox Code Playgroud)

android nativescript

1
推荐指数
1
解决办法
473
查看次数

geolocation.enableLocationRequest() 上的 nativescript-geolocation 崩溃

在模拟器nativescript-vue使用Android 10.0 (Pixel 3a)作为我的堆栈。

每当我调用geolocation.enableLocationRequest()onmounted()或 on button click 时,应用程序都会崩溃。

不过它在 iOS 上运行良好。

有任何想法吗?

更新 1 - 更多信息

清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android" package="__PACKAGE__" android:versionCode="10003" android:versionName="0.0.3">
    <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" />
    <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="__APILEVEL__" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.FLASHLIGHT" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-feature android:name="android.hardware.camera"/>
    <uses-feature android:name="android.hardware.camera.flash"/>
    <application android:name="com.tns.NativeScriptApplication" android:allowBackup="true" android:icon="@drawable/icon" android:label="@string/app_name" android:usesCleartextTraffic="true" android:theme="@style/AppTheme">
        <activity android:name="com.tns.NativeScriptActivity"
                  android:label="@string/title_activity_kimera"
                  android:configChanges="keyboardHidden|orientation|screenSize" …
Run Code Online (Sandbox Code Playgroud)

android nativescript nativescript-vue

1
推荐指数
1
解决办法
723
查看次数

原生脚本。AAPT:错误:未找到样式属性“android:attr/forceDarkAllowed”

我正在尝试运行我从示例中获得的第一个 NativeScript 应用程序 HelloWorld 并收到消息:

AAPT:错误:未找到样式属性“android:attr/forceDarkAllowed”。

错误信息截图

android nativescript

1
推荐指数
1
解决办法
1902
查看次数

我无法获得在 android 10 api 29 或 api 30 上工作的 http 请求。不过它确实适用于较低的 api

我正在使用 Telerik NativeScript 平台编写一个 Android 购物应用程序。我需要获取订单和交付的客户详细信息,因此我让他们在初始启动时进行注册。该应用程序适用于 API 17 到 API 28,我不知道是什么阻止了它在 API 29 和 API 30 上工作。如果我不能让它工作,我将无法将订单发送回网络应用程序工作。编码:-

const Observable = require("tns-core-modules/data/observable").Observable;
const fs = require("tns-core-modules/file-system");
const formObject = require("tns-core-modules/data/observable").fromObject;
const http = require("tns-core-modules/http/");
const Toast = require("nativescript-toast");

const dirPath = fs.knownFolders.documents();
const folder = dirPath.getFolder('sot');

const m = {
 name: "",
 email: "",
 password: "",
 phone: "",
 address: ""
};

const bindingContext = formObject(m);

exports.onLoad = args => {
 const p = args.object;
 p.bindingContext = bindingContext;

 let txtfile = fs.path.join(dirPath.path, …
Run Code Online (Sandbox Code Playgroud)

javascript android json nativescript

1
推荐指数
1
解决办法
1970
查看次数

Nativescript:为 iOS 模拟器构建错误

我遵循了 Mac (Big Sur) 上 nativescript 的完整安装指南。此外,在运行 tns doctor 时,一切似乎都很好。但是,当我运行 tns build ios 或 tns run ios 时,出现以下错误:

错误:为 iOS 模拟器构建,但链接和嵌入式框架“TNSWidgets.framework”是为 iOS + iOS 模拟器构建的。(在项目“projectapp”的目标“projectapp”中)。

有人可以告诉我如何解决这个问题。我安装了 nativescript 7.0.11 和 x-code 12.3

xcode ios-simulator nativescript

1
推荐指数
2
解决办法
1402
查看次数