如何在 iOS 上獲取裝置品牌和型號?


當我們談論裝置品牌時,指的是手機制造商(例如 Apple、三星、諾基亞等),而裝置型號通常是特定產品,如 iPhone、iPad/TAB 等。

所有移動裝置將僅使用品牌和型號進行分類。

現在讓我們瞭解如何在 iOS 中獲取裝置品牌和型號?

獲取品牌和型號有兩種方法,第一種方法是直接開啟 iOS 裝置,轉到設定,點選常規,然後在關於部分中你可以找到你的 iOS 裝置的詳細資訊

第二種方法是使用獲取品牌和型號

開啟 Xcode → 新專案,並在 ViewController 的 viewDidLoad 方法中新增以下程式碼。

let modelName = UIDevice.current.model
let name = UIDevice.current.name

print(modelName) // iPhone
print(name) // iPhone XR

UIDevice.current.model 會告訴你型號,是 iPhone 還是 iPad,UIDevice.current.name 會提供一個標識裝置的名稱。


更新時間:2019 年 7 月 30 日

2K+ 瀏覽

開啟您的 職業

透過完成課程獲得認證

開始
廣告
© . All rights reserved.