標籤:android style http 使用 os art
原地址:http://www.aichengxu.com/article/%CF%B5%CD%B3%D3%C5%BB%AF/28797_12.html
Unity3D與iOS的互動設計<ViewController 的跳轉>,有需要的朋友可以參考下。
這也是第一次做這樣的需求,也是公司的需要呀。做出這個真是一言難盡呀。。。
小弟主要不是搞iOS開發的,一直以來都是開發Android開發,只是昨天被老大叫過去做一下iOS的二維碼掃描。有點iOS基礎的我,只好到處搜尋了。然後,二維碼掃描做好了,遇到了一個難題,就是將做好的二維碼掃描放到Unity3D上去。這個好難呀。。。
剛開始吧,一直找不打rootController,嘗試了多次後,只好放棄了。最後自己繼承了一個View,仿製AlertDialog填充全屏,這樣算是草草了事。
具體操作如下:
1.這是Unity3D提供的一個按鈕點擊方法 <這個方法是根據Unity3D工程師大哥提供的,自己在 UnityAPPController類中手動添加的,至於為什麼是這個,我也不是很清楚,反正這個方法,Unity3D類中會調用,並執行下去>
extern "C" void setupCamera(){
//這是建立的一個視圖控制器對象,當然,是為了調用它裡面的stepC方法
UnityAppController *uni=[[UnityAppController alloc]init];
//這是需要調用的方法 [uni stepC];}
2.在UnityAppController中實現stepC方法
- (void)stepC{ //建立需要彈出的視圖 self.alert = [[MLCarAlert alloc]init]; // 自訂高度 self.alert.height = [UIScreen mainScreen].bounds.size.height; [self initNav]; // 顯示Alert [self.alert show];
}
這樣的話,就實現了視圖的跳轉,當然,有一個問題就是,自訂的dialog沒有擷取到焦點,這讓我很頭痛。還好按鈕只有一個,所以,在建立dialog的時候,我再定義了一個導覽列,通過導覽列添加按鈕,使用這個按鈕就解決了。<當然,如果布局控制項是在UnityAppController中添加的,就不會造成失去焦點這個問題,這個問題後來我也沒有解決,因為事情太多了。忙不過來。>
今天的時候,老大又讓我做一個介面,這個介面控制項就很多了。所以,上面那種方法就不行了。最後怎麼辦呢?
還好,找到了這樣的一個方法。
不停的尋找,不停的研究,不停的搜尋,後面終於在 iPhone_View.mm 中找到了我需要的rootViewController,如下:
UIViewController *UnityGetGLViewController()<span style="font-family: Arial, Helvetica, sans-serif;">{</span>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="white-space:pre"></span> return GetAppController().rootViewController;</span>
<span style="font-family: Arial, Helvetica, sans-serif;"> }</span>
<span style="font-family:Arial, Helvetica, sans-serif;">這樣,就得到了Unity3D的rootViewController</span>
<span style="font-family:Arial, Helvetica, sans-serif;"></span>
<span style="font-family:Arial, Helvetica, sans-serif;">然後就好辦啦,將自己的ViewController copy 到工程中,</span>
<span style="font-family:Arial, Helvetica, sans-serif;">建立:TableFormViewController *table=[[TableFormViewController alloc]init];</span>
<span style="font-family:Arial, Helvetica, sans-serif;">跳轉:[UnityGetGLViewController() presentViewController:table animated:YES completion:nil];</span>
這樣的話,就可以進自己的ViewController中操作啦。。
如果,有高手路過,還請指點指點呀。