当前位置: 编程技术>移动开发
本页文章导读:
▪unity3d 统制OnGUI unity3d 控制OnGUIvoid OnGUI()
GUILayout.Label("had mouse down");
down = true;
......
▪ 依据经纬度获取当地的位置 根据经纬度获取当地的位置package com.okhiking;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.........
▪ Objective-C的delloc步骤中,将对象置为nil和将对象release的区别 Objective-C的delloc方法中,将对象置为nil和将对象release的区别阅读别人代码的时候,经常会在delloc方法中,看到有的人释放对象使用self.xxx=nil,有些人使用[xxx release];就忍不住想查看一下这两者.........
[1]unity3d 统制OnGUI
来源: 互联网 发布时间: 2014-02-18
unity3d 控制OnGUI
有时我们想要在一些按钮或鼠标事件之后在让OnGUI画出里面的东西、 bool down = false; void OnGUI() { if (down) GUILayout.Label("had mouse down"); if (Event.current.type == EventType.MouseDown) down = true; }
参考:http://forum.unity3d.com/threads/29058-error-with-no-side-effects
[2] 依据经纬度获取当地的位置
来源: 互联网 发布时间: 2014-02-18
根据经纬度获取当地的位置
package com.okhiking;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONObject;
import android.content.Context;
import android.util.Log;
import com.okhiking.SLocation.SCell;
import com.okhiking.SLocation.SItude;
public class LocationUtil {
public static String getLocation(Double lat ,Double lon) throws Exception {
String resultString = "";
/** 这里采用get方法,直接将参数加到URL上 */
String urlString = String.format(
"http://maps.google.com/maps/geo?key=abcdefg&q=%s,%s",
lat, lon);
Log.i("URL", urlString);
/** 新建HttpClient */
HttpClient client = new DefaultHttpClient();
/** 采用GET方法 */
HttpGet get = new HttpGet(urlString);
try {
/** 发起GET请求并获得返回数据 */
HttpResponse response = client.execute(get);
HttpEntity entity = response.getEntity();
BufferedReader buffReader = new BufferedReader(
new InputStreamReader(entity.getContent()));
StringBuffer strBuff = new StringBuffer();
String result = null;
while ((result = buffReader.readLine()) != null) {
strBuff.append(result);
}
resultString = strBuff.toString();
/** 解析JSON数据,获得物理地址 */
if (resultString != null && resultString.length() > 0) {
JSONObject jsonobject = new JSONObject(resultString);
JSONArray jsonArray = new JSONArray(jsonobject.get("Placemark")
.toString());
resultString = "";
for (int i = 0; i < jsonArray.length(); i++) {
resultString = jsonArray.getJSONObject(i).getString(
"address");
}
}
} catch (Exception e) {
throw new Exception("获取物理位置出现错误:" + e.getMessage());
} finally {
get.abort();
client = null;
}
return resultString;
}
}
[3] Objective-C的delloc步骤中,将对象置为nil和将对象release的区别
来源: 互联网 发布时间: 2014-02-18
Objective-C的delloc方法中,将对象置为nil和将对象release的区别
阅读别人代码的时候,经常会在delloc方法中,看到有的人释放对象使用self.xxx=nil,有些人使用[xxx release];就忍不住想查看一下这两者的区别;
搜索资料之后,看到网上找到如下说法:
self.xxx = nil;等价于[xxx release]; xxx = [nil retain];
所以以后在delloc方法中,还是尽量用self.xxx = nil吧
最新技术文章: