• A-Fu Design
  • 前端設計
    • jQuery 套件
    • HTML 5
  • 關於A-Fu
  • 隱私權政策
  • 聯絡A-Fu
Google+ facebook twitter

A-Fu Design

A-Fu Design

Facebook Open Source React Native
AlertIOS

AlertIOS提供了使用消息創建iOS警報對話框或創建用戶輸入提示的功能。


創建iOS警報:

AlertIOS.alert(
 'Sync Complete',
 'All your data are belong to us.'
);
創建iOS提示:
AlertIOS.prompt(
  'Enter a value',
  null,
  text => console.log("You entered "+text)
);
如果您不需要創建僅限iOS的提示,我們建議使用Alert.alert方法進行跨平台支持。

Methods

  • alert
  • prompt

Type Definitions

  • AlertType
  • AlertButtonStyle
  • ButtonsArray

參考

Methods

alert()

static alert(title: string, [message]: string, [callbackOrButtons]: ?(() => void), ButtonsArray, [type]: AlertType): [object Object]
創建並顯示彈出警報。
參數:
NAMETYPEREQUIREDDESCRIPTION
titlestringYes對話框的標題。傳遞null或''將隱藏標題。
messagestringNo對話框標題下方顯示的可選消息。
callbackOrButtons?(() => void),ButtonsArrayNo此可選參數應該是單參數函數或按鈕數組。如果傳遞了一個函數,當用戶點擊“確定”時將調用它。如果傳遞了一組按鈕配置,則每個按鈕應包含一個文本鍵,以及可選的onPress和样式鍵。風格應該是'默認','取消'或'破壞性'之一。
typeAlertTypeNo已過時,請勿使用。
自定義按鈕示例:
AlertIOS.alert(
  'Update available',
  'Keep your app up to date to enjoy the latest features',
  [
    {
      text: 'Cancel',
      onPress: () => console.log('Cancel Pressed'),
      style: 'cancel',
    },
    {
      text: 'Install',
      onPress: () => console.log('Install Pressed'),
    },
  ]
);

prompt()

static prompt(title: string, [message]: string, [callbackOrButtons]: ?((text: string) => void), ButtonsArray, [type]: AlertType, [defaultValue]: string, [keyboardType]: string): [object Object]
創建並顯示輸入某些文本的提示。
參數:
NAMETYPEREQUIREDDESCRIPTION
titlestringYes對話框的標題。
messagestringNo在文本輸入上方顯示的可選消息。
callbackOrButtons?((text: string) => void),ButtonsArrayNo此可選參數應該是單參數函數或按鈕數組。如果傳遞了一個函數,當用戶點擊“確定”時,將使用提示符值調用它。如果傳遞了一組按鈕配置,則每個按鈕應包含一個文本鍵,以及可選的onPress和样式鍵(參見示例)。風格應該是'默認','取消'或'破壞性'之一。
typeAlertTypeNo此配置文本輸入。 “純文本”,“安全文本”或“登錄密碼”之一。
defaultValuestringNo文本輸入中的默認文本。
keyboardTypestringNo第一個文本字段的鍵盤類型(如果存在)。 One of 'default', 'email-address', 'numeric', 'phone-pad', 'ascii-capable', 'numbers-and-punctuation', 'url', 'number-pad', 'name-phone-pad', 'decimal-pad', 'twitter' or 'web-search'.
自定義按鈕示例:
AlertIOS.prompt(
  'Enter password',
  'Enter your password to claim your $1.5B in lottery winnings',
  [
    {
      text: 'Cancel',
      onPress: () => console.log('Cancel Pressed'),
      style: 'cancel',
    },
    {
      text: 'OK',
      onPress: (password) => console.log('OK Pressed, password: ' + password),
    },
  ],
  'secure-text'
);
,
使用默認按鈕和自定義回調的示例:
AlertIOS.prompt(
  'Update username',
  null,
  (text) => console.log('Your username is ' + text),
  null,
  'default'
);

類型定義

AlertType

An Alert button type
TYPE
$Enum
常量:
VALUEDESCRIPTION
default默認警報沒有輸入
plain-text純文本輸入警報
secure-text安全文本輸入警報
login-password登錄和密碼警報

AlertButtonStyle

警報按鈕樣式
TYPE
$Enum
常量:
VALUEDESCRIPTION
default默認按鈕樣式
cancel取消按鈕樣式
destructive破壞性按鈕樣式

ButtonsArray

數組或按鈕

TYPE
Array
常量:
NAMETYPEDESCRIPTION
[text]string按鈕標籤
[onPress]function按下按鈕時onPress回調功能
[style]AlertButtonStyle按鈕樣式
常量:
VALUEDESCRIPTION
text按鈕標籤
onPress按下按鈕時onPress回調功能
style按鈕樣式




Share
Tweet
Pin
Share
No 意見
Newer Posts
Older Posts

About me

還在努力掙扎中的工程師

Follow Us

  • Google+
  • facebook
  • twitter

Categories

Accordion Animation AutoComplete CSS Calendar Canvas Carousel Charts Color DatePicker Effects Facebook API Forms Gallery HTML5 Menu Mootools Prototype React images jQuery javascripts lightbox 前端技術 統計圖表 網頁設計

Recent Posts

  • Security Eye 4.4.1 免費網路攝影機監視系統,多路監視器解決方案
  • PotPlayer 1.7.16291 繁體中文免安裝,新增串流媒體播放的 MP4 格式
  • 微軟推出 Font Maker 製作自己專屬 「手寫字型」
  • jQuery Gantt Chart 在網頁上繪製甘特圖的 jQuery 套件
  • Kalendae 一個不依賴任何框架的日期選擇器

Sponsor


勸敗攻略
勸敗分部

Facebook

Blog Archive

  • 6月 2026 (27)
  • 5月 2026 (60)
  • 4月 2026 (58)
  • 3月 2026 (62)
  • 2月 2026 (55)
  • 1月 2026 (62)
  • 12月 2025 (62)
  • 11月 2025 (58)
  • 10月 2025 (62)
  • 9月 2025 (60)
  • 8月 2025 (62)
  • 7月 2025 (62)
  • 6月 2025 (58)
  • 4月 2025 (48)
  • 3月 2025 (60)
  • 2月 2025 (51)
  • 1月 2025 (56)
  • 12月 2024 (61)
  • 11月 2024 (60)
  • 10月 2024 (54)
  • 9月 2024 (55)
  • 8月 2024 (42)
  • 7月 2024 (40)
  • 6月 2024 (19)
  • 9月 2023 (3)
  • 4月 2023 (2)
  • 2月 2023 (1)
  • 12月 2021 (1)
  • 1月 2019 (11)
  • 12月 2018 (31)
  • 11月 2018 (31)
  • 10月 2018 (31)
  • 9月 2018 (30)
  • 8月 2018 (31)
  • 7月 2018 (3)
  • 2月 2018 (1)
  • 4月 2015 (1)
  • 9月 2014 (1)
  • 2月 2014 (1)
  • 7月 2013 (1)
  • 2月 2013 (2)
  • 1月 2013 (1)
  • 12月 2012 (12)
  • 11月 2012 (81)
  • 10月 2012 (64)

Created with by ThemeXpose | Distributed by Blogger Templates