Just My Life & My Work

Archive for the ‘教學’ Category

[iOS] TextView 縮回虛擬鍵盤

我們已經知道如何讓TextField輸入完成讓鍵盤消失,現在想要使TextView 縮回虛擬鍵盤,可以怎麼做呢?

TextView 縮回虛擬鍵盤

TextView設定好delegate,並實作protocol的method如下。當鍵盤升起時,按下Done,即可讓它縮回去~

/**
 Theme: Text View Done Resign First Response
 IDE: Xcode 6
 Language: Objective C
 Date: 104/03/35
 Author: HappyMan
 Blog: https://cg2010studio.wordpress.com/
 */
#pragma mark -
#pragma mark - UITextFieldDelegate
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
    if ([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
        // Return FALSE so that the final '\n' character doesn't get added
        return NO;
    }
    // For any other character return TRUE so that the text gets added to the view
    return YES;
}

參考:UITextView resign first responder on ‘Done’

[iOS] 發佈版本給使用者測試 (Crashlytics Distribution for User Test)

曾經陪我們測試過許多App的平台Testflight,即將在這個月底(2/26)結束營業XD~好啦,其實是被Apple買去,整合到iTunes Connect中,未來可以去嘗試看看。

crashlytics

在此,我要介紹另一個發佈版本給使用者測試平台Crashlytics,它有三大功能:

  1. 回報崩潰事件
  2. 追蹤使用者狀況
  3. 發布版本給使用者測試

過去我很常使用1和2,現在可以來嘗試3。

(繼續閱讀…)

[Git] 設定.gitignore忽略追蹤檔案

Git是個博大精深的好工具,它可以用來管理檔案的版本,不過我們不需要所有功能都學會,只要學習我們所需要的功能即可!現在我需要忽略追蹤檔案,可以怎麼做呢?

Git 設定.gitignore忽略追蹤檔案

 

因為bin和obj兩個資料夾太過肥大,它是由原始碼編譯後產生的衍生檔,檔案大小動輒上百MB,因為可以重新生成,所以沒必要去追蹤。

過去我只會在專案頭目錄push所有檔案,現在想要忽略這兩個資料夾可以這麼做,在終端機輸入:

vi .gitignore

然後我就可以設定.gitignore這個檔案:

3rd Library/AwesomeMenuProject/AwesomeMenuProject/bin

3rd Library/AwesomeMenuProject/AwesomeMenuProject/obj

儲存後關閉,此後再push所有檔案,就會忽略此bin和obj兩個資料夾囉!

參考:[GIT] 設定.gitignore 忽略檔案不被track

[Xamarin][iOS] 多螢幕:電話字 (Sample Project: Phoneword)

承接深度了解專案:電話字 (Sample Project: Phoneword),再來學習多螢幕架構,同樣也是跟Xcode非常相似的做法,看到介面很快就能上手!

Xamarin phoneword00010

簡直就一模一樣嘛⋯⋯view controller的連結也是透過拉藍色線

過去我鮮少使用Storyboard,多使用Xib,不過因Apple一直在推廣Storyboard(範例程式都以它為主),我們豈能守舊而唯Xib獨尊?想想過去技術高手只想用code,來處理App所有層面的事情,現在看起來是多麽不切實際呢!之所以會發明新的工具,就是想增進開發效率,所以讓我們來擁抱改變吧!

(繼續閱讀…)

[Xamarin][iOS] 深度了解專案:電話字 (Sample Project: Phoneword)

承接範例專案:電話字 (Sample Project: Phoneword),再來就是解釋它怎麼運作,包含Xamarin介面C#程式碼,還有很重要的是Xamarin.iOS Application的剖析。

Xamarin iOS Application03

  • References – Contains the assemblies required to build and run the application. If we expand the directory, we’ll see references to .NET assemblies such as System , System.Core, and System.Xml , as well as a reference to Xamarin’s Xamarin.iOS assembly.
  • Components – The Components directory houses ready-made features from the Xamarin Components store , a public marketplace for Xamarin code. This is similar to the NuGet Gallery for those familiar with Visual Studio. For more information on Xamarin Components, refer to the Xamarin Components walkthrough .
  • Resources – The Resources folder stores icons, launch images, and other media. Xamarin has a separate guide for Working with Resources that explores the role of this directory further.
  • Main.cs – This contains the main entry point of the application. To start the application, we pass in the name of the main application class, the AppDelegate .
  • AppDelegate.cs – This file contains the main application class and is responsible for creating the Window, building the user interface, and listening to events from the operating system.
  • MainStoryboard.storyboard – The Storyboard contains the visual design of the application’s user interface. Storyboard files open in a graphical editor called the iOS Designer.
  • Phoneword_iOSViewController.cs – The View Controller powers the screen (View) that a user sees and touches. The View Controller is responsible for handling interactions between the user and the View.
  • Phoneword_iOSViewController.designer.cs – The designer.cs is an auto-generated file that serves as the glue between controls in the View and their code representations in the View Controller. Because this is an internal plumbing file, the IDE will overwrite any manual changes and most of the time we can ignore this file. For more information on the relationship between the visual Designer and the backing code, refer to the Introduction to the iOS Designer guide.
  • Info.plist – Info.plist is where we set application properties such as the application name, icons, launch images, and more. This is a powerful file and a thorough introduction to it is available in theWorking with Property Lists guide.
  • Entitlements.plist – The entitlements property list lets us specify application capabilities (also called App Store Technologies) such as iCloud, PassKit, and more. More information on theEntitlements.plist can be found in the Working with Property Lists guide. For a general introduction to entitlements, refer to the Device Provisioning guide.

看起來和Xcode裡的檔案架構很類似呢!學習來格外輕鬆~

(繼續閱讀…)

[Xamarin][iOS] 範例專案:工作清單 (Sample Project: Tasky)

在瞭解Xamarin介紹與研究後,接著就去下載並且安裝Xamarin Studio,再來當然就是要來跑「飯粒」專案囉~如此可快速上手Xamarin!

官方提供的範例專案:工作清單 (Sample Project: Tasky),下載後開啟專案,即可直接編譯執行,除了在模擬器 (Simulator)上跑,也能在實機 (Device)上跑呢!而模擬器居然是開啟Xcode附帶的iOS模擬器,所以感覺相當親切:)~

Xamarin before

(繼續閱讀…)

[Xamarin][iOS] 範例專案:電話字 (Sample Project: Phoneword)

有目標的學習是最快學會一套工具的最好方式!於是乎,Xamarin官方的快速開始教學範例專案:電話字 (Sample Project: Phoneword),引領我熟悉這有著神秘面紗的IDE (整合開發環境)

Xamarin Phoneword

這畫面看起來是不是很像Xcode的樣子呀?!

(繼續閱讀…)

Xamarin 介紹與研究

因為有個新專案,必須開發兩個平台iOSAndroid,想要降低成本便選擇Xamarin這個方案,一年半前已經與同事們一起研究過它的特色,今日再次研究感覺特別不一樣,因為Xamarin又進化許多啦~

Xamarin

(繼續閱讀…)

[iOS] 延長顯示啟動畫面的時間

Launch Image (Launch Screen)顯示時間是由系統決定,不過我們可透過讓App睡覺的方式,來延長顯示啟動畫面的時間

iPhone_6_Garbage_launch

垃圾管家App開啟畫面為例。

只要一行程式碼,即可做到延遲的效果喔!在AppDelegate.m中:


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    sleep(5);
}

參考:increase launch image time on xcode

[iOS] iOS 8 Remote/Local Notification

每年iOS更新後,SDK中多少會有些API在最新的版本被棄用,此時就要去寫condition code分別跑在不同版本的iOS。Notification也在iOS 8有所變動,包含Remote Notification與Local Notification,我們就來看怎麼改比較容易吧~

iOS 8 Remote:Local Notification

如果沒有處理iOS 8的情況,是不會跳出請求允許傳送通知的提示喔!

(繼續閱讀…)

標籤雲