【Delphi XE4】iOS開發教學文件

Embarcadero官方的文件 iOS Tutorials: Delphi iOS Application Development ,對於使用Delphi XE4開發iOS有興趣的朋友,一定得下載下來看看的好文件。

下載網址: http://docs.embarcadero.com/products/rad_studio/radstudioXE4/iOS%20Tutorial%20en.pdf

【Delphi XE4】定位功能

示範如果快速使用Delphi XE4開發iOS定位功能的程式

1.建立一個新的FireMonkey Mobile Application

未命名 - 1

2.選擇 Blank Application 空白類型。

未命名 - 2

3.新增元件ListBox,將 Align 改為 alTop; GroupingKind 改為 GsGrouped;StyleLookup 改為 transparentlistboxstyle。

未命名 - 3

4. ListBox按右鍵,Add Item 新增 TListBoxHeader,在裡面新增Label ,屬性 Align 設為 alClient ; StyleLookup 設為 toollabel ; TextAlign 設為 taCenter。

未命名 - 7

5. 接著新增三個 TListBoxItem,分別是開啟定位、經度、緯度。在開啟定位的右側新增TSwitch開關來開啟定位功能。經度、緯度使用TLabel。

未命名 - 22

未命名 - 15

6.接著在畫面上佈置TWebBrowser跟TLocationSensor,TWebBrowser的 Align 設為 alClient。

未命名 - 16未命名 - 18

7.佈置好的畫面如下圖

未命名 - 24

8. 在Switch1 的 OnSwitch 事件中新增程式如下

[delphi]
procedure TForm1.Switch1Switch(Sender: TObject);
begin
LocationSensor1.Active := Switch1.IsChecked ;
end;
[/delphi]

9.接著在 LocationSensor1 的 OnLocationChange事件中新增程式如下

[delphi]
procedure TForm1.LocationSensor1LocationChanged(Sender: TObject;
const OldLocation, NewLocation: TLocationCoord2D);
const
sGoogleMapURL : String = ‘https://maps.google.com/maps?q=%s,%s&output=embed’;
begin
label3.Text := ‘經度: ‘ + NewLocation.Latitude.ToString;
label2.Text := ‘緯度: ‘ + NewLocation.Longitude.ToString;

WebBrowser1.Navigate(Format(sGoogleMapURL,
[NewLocation.Latitude.ToString,
NewLocation.Longitude.ToString]));
end;
[/delphi]

10.大功告成!我們來看執行結果

螢幕快照 2013-05-19 上午11.16.43

螢幕快照 2013-05-19 上午11.22.22

Eclipse出現adt錯誤訊息

打開Eclipse出現以下訊息~

The Android SDK requires Android Developer Toolkit version 21.1.0 or above.
Current version is 21.0.1.2012-12-6-2-58.
Please update ADT to the latest version.

接著還出現 ”installing software has encountered a problem”

解決方式:

Window → Preferences →  Install/Update → Available Software Sites

點選 adt 按 edit

將http://dl-ssl.google.com/android/eclipse/

改成 https://dl-ssl.google.com/android/eclipse/

您的密碼夠安全嗎?How Strong is Your Password?

隨著資訊越來越普及的關係,大家都習慣把資料放在網路上。像電子郵件、mail、通訊軟體等等,而這些服務都需要透過密碼認證才能進入,不過大家有思考您的密碼夠安全嗎?

password-checker

這是Intel公司的一個有趣服務,可以檢測一下您的密碼是否夠安全。

壽山為了驗證之前以注音符號打句子,但不切換成注音輸入的密碼。的確是易記又安全的方法!

例如:我愛豐原葫蘆墩(ji394z/m06cj6xj62jp)就要花1500823093年才能破解!

result

 

【Delphi XE3】編譯成Mac OS可執行程式 – 程式範例

上一篇文章中,筆者教大家如何在Mac系統中配置PAServer了,接下來要教大家如何設計可以同時執行在Windows及Mac OS的程式。

一、File→New選取FireMonkey Desktop Application

Fire Desktop Application

二、接下來選擇一般的HD FireMonkey Application

Select a firemonkey application type

三、新增專案後,在專案的Target Platform按右鍵,選擇Add Platform

add platform

四、接著選擇OS X後按ok

Select a Platform

五、接著在OS X按右鍵 Assign Remote Profile 設置OS X的編譯環境

Assign Remote Profile

六、Profile name填上你要的名字

Profile Information

七、Host name填上你在上一篇文章設置的MAC OS主機位置,password則設置上篇文章所設定的密碼。

Host Machine Information

 

八、按 Test Connection測試是否可以連得上(記得要執行paserver)

Test Connection

九、如果順利的話,按下Finish就大功告成!

Create Remote Profile

 

九、接著點選剛才建立的Platform名稱按OK!

Select Remote Profile

十一、如果設定沒錯的話,在XE3按下執行後,程式就會直接執行在Mac OS的畫面上囉!

Test Form

【Delphi XE3】編譯成Mac OS可執行程式 – mac os設置

1.安裝PAServer
將 \Program Files\Embarcadero\RAD Studio\10.0\PAServer中的setup_paserver.zip 複製到 Mac OSX系统
2.將setup_paserver.zip解壓縮進行安裝。
3.安裝完後,進行環境配置
\user\XXXX\Applications\Embarcadero\RADPAServer\10.0\,執行paserver
4.執行後,paserver會請您設定密碼,設定完後就配置ok!
5.利用文字編輯程式打開目錄下的 paserver.command,在第二行後面加上-password=xxxx,xxxx是你在上一步驟設定的密碼。儲存後關閉!
6.幫 paserver.command建立捷徑(替身),或是利用「系統偏好設定」→「帳號」→「登入項目」讓它隨系統啟動。

[PHP]計算二點間距離

[php]
#lat1,lon1是第一個點的經緯度
#lat2,lon2是第二個點的經緯度
#unit的話就用"K" (這樣的話傳回值就會是公尺)
function distance($lat1, $lon1, $lat2, $lon2, $unit) {
global $source;
$theta = $lon1 – $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$unit = strtoupper($unit);

if ($unit == "K") {
$meters = intval($miles * 1.609344 * 1000);
if($meters > 10000){
return intval($meters/1000).msg(‘公里’,’km’);
}else{
return $meters.msg(‘公尺’,’m’);
}
} else if ($unit == "N") {
return ($miles * 0.8684);
} else {
return $miles;
}
}
[/php]

台灣鐵路通Taiwan Railway – 考驗對車站的熟悉度

 

您是鐵道迷嗎?自認對台灣鐵路瞭若指掌嗎?那您可以來玩玩這款「台灣鐵路通Taiwan Railway」遊戲。

設計師魏巍 一手包辦了遊戲中的圖片、程式及音效,連宣傳影片都是自己拍攝的,可見對於APP的用心程度。

20130426-154702.jpg

遊戲的玩法也相當簡單,在畫面中會出現現在地及目的地二個提示。然後以手指拖拉列車往正確的方向即可!

20130426-154632.jpg

20130426-154742.jpg

所以遊戲的前提是,您要自認熟悉各個站名的先後順序,或是在遊戲中有相關的資訊供參考。

20130426-154725.jpg

下載網址:

iOS: https://itunes.apple.com/tw/app/id624473652?mt=8
Android: https://play.google.com/store/apps/details?id=com.appsgaga.game.taiwanrailway