把以下代码放在点解 “编辑” 按钮时触发的方法中。
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 0.001); dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ for (UIView *sv in self.self.tableView.subviews) { if ([sv isKindOfClass:[UITableViewCell class]]) { UITableViewCell *cell = (UITableViewCell *)sv; for (UIView *ssv in cell.subviews) { // 判断该subview是否为 删除按钮, 删除按钮坐标为:x:10.0 if (ssv.frame.origin.x == 10.0) { // 此处修改删除按钮样式,样例代码如下 IVTableViewCellEditControl *editControl = [[IVTableViewCellEditControl alloc] initWithImage:PNGImage(PASS_CELL_DELETE_ICON)]; editControl.frame = CGRectMake(10, 0, editControl.frame.size.width, editControl.frame.size.height); [cell addSubview:editControl]; [editControl release]; ssv.hidden = YES; [ssv setRotated:YES animated:YES]; UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 18.5, 21)]; imgView.image = PNGImage(PASS_CELL_DELETE_ICON); [imgView release]; } } } } });
不多说,直接上图:
下面是下载的链接地址:
第三集下载地址:http://www.400gb.com/file/24988347
第四集下载地址:http://www.400gb.com/file/24988473
https://developers.google.com/maps/documentation/geocoding/?hl=zh-CN#GeocodingRequests获得google的GPS服务的api文档
package com.hhj.gps;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;
/*import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.Projection;*/
import android.R.integer;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class GoogleGeographyQuery{
static double lng;
static double lat;
/*查询经纬度*/
public static double[] jingweidu(String AddressName){
//List<Map<String, Object>> mData=new ArrayList<Map<String, Object>>();
String url = "http://maps.googleapis.com/maps/api/geocode/json?address=" + AddressName + "&sensor=false";
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(url);
try {
HttpResponse response = client.execute(get);
HttpEntity entity = response.getEntity();
InputStream input = entity.getContent();
int t;
StringBuffer buffer = new StringBuffer();
while ((t = input.read()) != -1) {
buffer.append((char) t);
}
//tv.setText(buffer);
// json解析
JSONObject object = new JSONObject(buffer.toString());
JSONObject location = object.getJSONArray("results")
.getJSONObject(0)// 获得中括号的内容
.getJSONObject("geometry")// 获得大括号中的内容
.getJSONObject("location");
lng = location.getDouble("lng");
lat = location.getDouble("lat");
Log.i("HHJ", "经纬度是 : "+lng+" "+lat);
double[] data ={lng,lat};
return data;
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public static String geocodeAddr(String latitude, String longitude) {
String addr = "";
// 也可以是http://maps.google.cn/maps/geo?output=csv&key=abcdef&q=%s,%s,不过解析出来的是英文地址
// 密钥可以随便写一个key=abc
// output=csv,也可以是xml或json,不过使用csv返回的数据最简洁方便解析
String url = String.format("http://ditu.google.cn/maps/geo?output=csv&key=abcdef&q=%s,%s",latitude, longitude);
URL myURL = null;
URLConnection httpsConn = null;
try {
myURL = new URL(/blog_article/url/index.html);
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
}
try {
httpsConn = (URLConnection) myURL.openConnection();
if (httpsConn != null) {
InputStreamReader insr = new InputStreamReader(httpsConn.getInputStream(), "UTF-8");
BufferedReader br = new BufferedReader(insr);
String data = null;
if ((data = br.readLine()) != null) {
System.out.println(data);
String[] retList = data.split(",");
if (retList.length > 2 && ("200".equals(retList[0]))) {
addr = retList[2];
addr = addr.replace("\"", "");
} else {
addr = "";
}
Log.i("HHJ", "123 : "+addr);
}
insr.close();
}
} catch (IOException e) {
e.printStackTrace();
return null;
}
return addr;
}
}