0

Fire、Nook、iOS などのデバイスごとに異なるコードを実行するために、Corona SDK を取得しようとしています。

どのデバイスが使用されているかを実行時に検出し、デバイスごとに異なるコードを実行できるようにするプリプロセッサ ステートメントはありますか?

4

1 に答える 1

2

そして、ここに答えがあります:

http://www.coronalabs.com/blog/2012/12/11/device-detection-on-steroids/

デバイス文字列をテストします。

    if (system.getInfo("model") == "iPad" or system.getInfo("model") == "iPhone" or   system.getInfo("model") == "iPod") then
      -- ios code here
    else
      if (system.getInfo("model") ~= "Kindle Fire") then
        -- amazon code here
      elseif (system.getInfo("model") ~= "Nook" ) then
        -- nook code here
      else
        -- google code here
      end
    end

ifブログは、常にコード内でステートメントを使用するのではなく、独自のデバイス ライブラリ関数を作成する優れた方法を提供します。

于 2013-01-04T18:57:59.533 に答える