For the complete documentation index, see llms.txt. This page is also available as Markdown.

关闭屏幕


1. 关闭页面(closeView)

这是一个关闭当前页面的函数。可以在按下“关闭”按钮并结束服务时使用。

签名

function closeView(): Promise<void>;

示例

import { Button } from 'react-native';
import { closeView } from '@granite-js/react-native';

function CloseButton() {
  return <Button title="关闭" onPress={closeView} />;
}

2. 设置 iOS 滑动返回(setIosSwipeGestureEnabled)

在 iOS 上启用或禁用通过滑动屏幕返回的手势。

签名

function setIosSwipeGestureEnabled(options: { isEnabled: boolean }): Promise<void>;

参数

  • options.isEnabled · 必填 · boolean

    true时,可以通过滑动返回, false时,滑动返回会被禁用。

示例


3. 控制返回事件(useBackEvent)

这是一个可以注册和移除返回事件的 Hook。只有在特定组件处于激活状态时,才能处理返回事件。

签名

返回值

  • BackEventControls

    这是一个控制返回事件的对象。 addEventListener用于注册事件, removeEventListener用于移除。

请注意

这个 Hook 必须 BackEventProvider 在其中使用。否则会发生错误。

示例

最后更新于

这有帮助吗?