当前位置:  编程技术>移动开发
本页文章导读:
    ▪frame.bounds跟center        frame.bounds和centerCGPoint point=CGPoint(x,y);  //表示位置 CGSize size=CGSzieMake(width,height);  //表示大小 CGRect rect=CGRectMake(x,y,width,height) 1.frame: 描述当前视图在其父视图中的位置和大小,用位置坐标和长.........
    ▪ 百度map之自定义绘制功能        百度地图之自定义绘制功能我们可以在地图上绘制各种自定义的图形,包括点、折线、圆、多边形等等,尤其绘制点和折线非常实用,点可以用来标识所处的位置,折线可以用来描述走过的.........
    ▪ xcode 模拟器没法正常运行的解决       xcode 模拟器无法正常运行的解决原始地址:xcode 模拟器无法正常运行的解决 出现情况:xcode build 模拟器后,第一次模拟器打开,停在launch image处,无任何debug信息。关闭模拟器重新build,Run和St.........

[1]frame.bounds跟center
    来源: 互联网  发布时间: 2014-02-18
frame.bounds和center

CGPoint point=CGPoint(x,y);  //表示位置

CGSize size=CGSzieMake(width,height);  //表示大小

CGRect rect=CGRectMake(x,y,width,height)

1.frame:

描述当前视图在其父视图中的位置和大小,用位置坐标和长度来表示:

sample:

UIButton *button3=[[[UIButtonalloc]initWithFrame:CGRectMake(120,120,100,100)]autorelease];

    button3.backgroundColor=[UIColorgreenColor];

    [self.view addSubview:button3];

    NSLog(@"the result is %f,%f,%f,%f",button3.frame.size.height,button3.frame.size.width,button3.frame.origin.x,button3.frame.origin.y);

结果:

the result is 100.000000,100.000000,120.000000,120.000000

2. bounds  property

描述当前视图在其自身坐标系统中的位置和大小。

iphone中坐标系统的建立,最左上角是原点(0,0),向右为x轴递增,想下为y轴递减。

ios采用CGPoint来表示点在坐标系上X、Y位置。我们可以通过CGPointMake(x,y)来创建一个坐标点:CGPoint point = CGPointMake(80,40)

同时,ios采用CGSize来表示视图的宽度和高度,即视图的大小。我们可以通过CGSizeMake(width,height)来创建一个矩形的大小,如CGSize size = CGSizeMake(144,72)将创建一个宽度为144,高度为72的矩形大小。

而CGRect则是结合了CGPoint和CGSize,用来表示矩形的位置和大小。它的origin表示矩形右上角所在位置(CGPoint),size表示矩形的大小(CGSize)。

sample:

  UIButton *button3=[[[UIButton alloc] initWithFrame:CGRectMake(120, 120, 100, 100)] autorelease];
    button3.backgroundColor=[UIColor greenColor];
    [self.view addSubview:button3];
    NSLog(@"the result is %f,%f,%f,%f",button3.frame.size.height,button3.frame.size.width,button3.frame.origin.x,button3.frame.origin.y);
    
    NSLog(@"the result is %f,%f,%f,%f",button3.bounds.origin.x,button3.bounds.origin.y,button3.bounds.size.height,button3.bounds.size.width);
}

3.center  property

描述当前视图的中心点在其父视图中的位置。

sample如下所示:

    UIButton *button3=[[[UIButton alloc] initWithFrame:CGRectMake(120, 120, 100, 100)] autorelease];
    button3.backgroundColor=[UIColor greenColor];
    [self.view addSubview:button3];
    NSLog(@"the result is %f,%f",button3.center.x,button3.center.y);
result is:

the result is 170.000000,170.000000

4.frame.bounds 和center的区别和联系

这两个属性都是用来描述视图的大小(CGSize)和位置(CGPoint)的,两者都用CGRect表示。不同的是,frame描述的是在其父视图中的CGRect,而bounds描述的是在其自身视图中的CGRect,

center属性则用CGPoint表示矩形中心点在其父视图中的位置,frame、bounds和center三个属性是相互关联、相互影响的,其中一个属性发生变化,其他属性也会跟着变化。



    
[2] 百度map之自定义绘制功能
    来源: 互联网  发布时间: 2014-02-18
百度地图之自定义绘制功能

我们可以在地图上绘制各种自定义的图形,包括点、折线、圆、多边形等等,尤其绘制点和折线非常实用,点可以用来标识所处的位置,折线可以用来描述走过的轨迹,结合前面GPS定位功能可以做出一些非常有意思的应用,下面应用百度Demo实现绘制的基本功能,代码如下:

Activity:

package com.home;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.baidu.mapapi.map.Geometry;
import com.baidu.mapapi.map.Graphic;
import com.baidu.mapapi.map.GraphicsOverlay;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.Symbol;
import com.baidu.mapapi.map.TextItem;
import com.baidu.mapapi.map.TextOverlay;
import com.baidu.platform.comapi.basestruct.GeoPoint;

/**
 * 此demo用来展示如何在地图上用GraphicsOverlay添加点、线、多边形、圆 同时展示如何在地图上用TextOverlay添加文字
 * 
 */
public class GeometryActivity extends Activity implements OnClickListener {

	// 地图相关
	private MapView mMapView = null;

	private Button resetBtn = null;
	private Button clearBtn = null;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_geometry);
		CharSequence titleLable = "自定义绘制功能";
		setTitle(titleLable);

		// 初始化地图
		mMapView = (MapView) findViewById(R.id.bmapView);
		mMapView.getController().setZoom(12.5f);
		mMapView.getController().enableClick(true);

		// UI初始化
		clearBtn = (Button) findViewById(R.id.btn_clear);
		resetBtn = (Button) findViewById(R.id.btn_reset);
		clearBtn.setOnClickListener(this);
		resetBtn.setOnClickListener(this);
		resetBtn.setEnabled(false);

		// 界面加载时添加绘制图层
		addCustomElementsDemo();
	}

	@Override
	public void onClick(View v) {
		if (v == clearBtn) {
			clearClick();
			clearBtn.setEnabled(false);
			resetBtn.setEnabled(true);
		}
		if (v == resetBtn) {
			resetClick();
			clearBtn.setEnabled(true);
			resetBtn.setEnabled(false);
		}
	}

	/**
	 * 清除所有图层
	 */
	public void clearClick() {
		mMapView.getOverlays().clear();
	}

	/**
	 * 添加绘制元素
	 */
	public void resetClick() {
		addCustomElementsDemo();
	}

	/**
	 * 添加点、线、多边形、圆、文字
	 */
	public void addCustomElementsDemo() {
		GraphicsOverlay graphicsOverlay = new GraphicsOverlay(mMapView);
		mMapView.getOverlays().add(graphicsOverlay);
		// 添加点
		graphicsOverlay.setData(drawPoint());
		// 添加折线
		graphicsOverlay.setData(drawLine());
		// 添加多边形
		graphicsOverlay.setData(drawPolygon());
		// 添加圆
		graphicsOverlay.setData(drawCircle());
		// 绘制文字
		TextOverlay textOverlay = new TextOverlay(mMapView);
		mMapView.getOverlays().add(textOverlay);
		textOverlay.addText(drawText());
		// 执行地图刷新使生效
		mMapView.refresh();
	}

	/**
	 * 绘制折线,该折线状态随地图状态变化
	 * 
	 * @return 折线对象
	 */
	public Graphic drawLine() {
		double mLat = 39.97923;
		double mLon = 116.357428;

		int lat = (int) (mLat * 1E6);
		int lon = (int) (mLon * 1E6);
		GeoPoint pt1 = new GeoPoint(lat, lon);

		mLat = 39.94923;
		mLon = 116.397428;
		lat = (int) (mLat * 1E6);
		lon = (int) (mLon * 1E6);
		GeoPoint pt2 = new GeoPoint(lat, lon);
		mLat = 39.97923;
		mLon = 116.437428;
		lat = (int) (mLat * 1E6);
		lon = (int) (mLon * 1E6);
		GeoPoint pt3 = new GeoPoint(lat, lon);

		// 构建线
		Geometry lineGeometry = new Geometry();
		// 设定折线点坐标
		GeoPoint[] linePoints = new GeoPoint[3];
		linePoints[0] = pt1;
		linePoints[1] = pt2;
		linePoints[2] = pt3;
		lineGeometry.setPolyLine(linePoints);
		// 设定样式
		Symbol lineSymbol = new Symbol();
		Symbol.Color lineColor = lineSymbol.new Color();
		lineColor.red = 255;
		lineColor.green = 0;
		lineColor.blue = 0;
		lineColor.alpha = 255;
		lineSymbol.setLineSymbol(lineColor, 10);
		// 生成Graphic对象
		Graphic lineGraphic = new Graphic(lineGeometry, lineSymbol);
		return lineGraphic;
	}

	/**
	 * 绘制多边形,该多边形随地图状态变化
	 * 
	 * @return 多边形对象
	 */
	public Graphic drawPolygon() {
		double mLat = 39.93923;
		double mLon = 116.357428;
		int lat = (int) (mLat * 1E6);
		int lon = (int) (mLon * 1E6);
		GeoPoint pt1 = new GeoPoint(lat, lon);
		mLat = 39.91923;
		mLon = 116.327428;
		lat = (int) (mLat * 1E6);
		lon = (int) (mLon * 1E6);
		GeoPoint pt2 = new GeoPoint(lat, lon);
		mLat = 39.89923;
		mLon = 116.347428;
		lat = (int) (mLat * 1E6);
		lon = (int) (mLon * 1E6);
		GeoPoint pt3 = new GeoPoint(lat, lon);
		mLat = 39.89923;
		mLon = 116.367428;
		lat = (int) (mLat * 1E6);
		lon = (int) (mLon * 1E6);
		GeoPoint pt4 = new GeoPoint(lat, lon);
		mLat = 39.91923;
		mLon = 116.387428;
		lat = (int) (mLat * 1E6);
		lon = (int) (mLon * 1E6);
		GeoPoint pt5 = new GeoPoint(lat, lon);

		// 构建多边形
		Geometry polygonGeometry = new Geometry();
		// 设置多边形坐标
		GeoPoint[] polygonPoints = new GeoPoint[5];
		polygonPoints[0] = pt1;
		polygonPoints[1] = pt2;
		polygonPoints[2] = pt3;
		polygonPoints[3] = pt4;
		polygonPoints[4] = pt5;
		polygonGeometry.setPolygon(polygonPoints);
		// 设置多边形样式
		Symbol polygonSymbol = new Symbol();
		Symbol.Color polygonColor = polygonSymbol.new Color();
		polygonColor.red = 0;
		polygonColor.green = 0;
		polygonColor.blue = 255;
		polygonColor.alpha = 126;
		polygonSymbol.setSurface(polygonColor, 1, 5);
		// 生成Graphic对象
		Graphic polygonGraphic = new Graphic(polygonGeometry, polygonSymbol);
		return polygonGraphic;
	}

	/**
	 * 绘制单点,该点状态不随地图状态变化而变化
	 * 
	 * @return 点对象
	 */
	public Graphic drawPoint() {
		double mLat = 39.98923;
		double mLon = 116.397428;
		int lat = (int) (mLat * 1E6);
		int lon = (int) (mLon * 1E6);
		GeoPoint pt1 = new GeoPoint(lat, lon);

		// 构建点
		Geometry pointGeometry = new Geometry();
		// 设置坐标
		pointGeometry.setPoint(pt1, 10);
		// 设定样式
		Symbol pointSymbol = new Symbol();
		Symbol.Color pointColor = pointSymbol.new Color();
		pointColor.red = 0;
		pointColor.green = 126;
		pointColor.blue = 255;
		pointColor.alpha = 255;
		pointSymbol.setPointSymbol(pointColor);
		// 生成Graphic对象
		Graphic pointGraphic = new Graphic(pointGeometry, pointSymbol);
		return pointGraphic;
	}

	/**
	 * 绘制圆,该圆随地图状态变化
	 * 
	 * @return 圆对象
	 */
	public Graphic drawCircle() {
		double mLat = 39.90923;
		double mLon = 116.447428;
		int lat = (int) (mLat * 1E6);
		int lon = (int) (mLon * 1E6);
		GeoPoint pt1 = new GeoPoint(lat, lon);

		// 构建圆
		Geometry circleGeometry = new Geometry();

		// 设置圆中心点坐标和半径
		circleGeometry.setCircle(pt1, 2500);
		// 设置样式
		Symbol circleSymbol = new Symbol();
		Symbol.Color circleColor = circleSymbol.new Color();
		circleColor.red = 0;
		circleColor.green = 255;
		circleColor.blue = 0;
		circleColor.alpha = 126;
		circleSymbol.setSurface(circleColor, 1, 3);
		// 生成Graphic对象
		Graphic circleGraphic = new Graphic(circleGeometry, circleSymbol);
		return circleGraphic;
	}

	/**
	 * 绘制文字,该文字随地图变化有透视效果
	 * 
	 * @return 文字对象
	 */
	public TextItem drawText() {
		double mLat = 39.86923;
		double mLon = 116.397428;
		int lat = (int) (mLat * 1E6);
		int lon = (int) (mLon * 1E6);
		// 构建文字
		TextItem item = new TextItem();
		// 设置文字位置
		item.pt = new GeoPoint(lat, lon);
		// 设置文件内容
		item.text = "百度地图SDK";
		// 设文字大小
		item.fontSize = 40;
		Symbol symbol = new Symbol();
		Symbol.Color bgColor = symbol.new Color();
		// 设置文字背景色
		bgColor.red = 0;
		bgColor.blue = 0;
		bgColor.green = 255;
		bgColor.alpha = 50;

		Symbol.Color fontColor = symbol.new Color();
		// 设置文字着色
		fontColor.alpha = 255;
		fontColor.red = 0;
		fontColor.green = 0;
		fontColor.blue = 255;
		// 设置对齐方式
		item.align = TextItem.ALIGN_CENTER;
		// 设置文字颜色和背景颜色
		item.fontColor = fontColor;
		item.bgColor = bgColor;
		return item;
	}

	@Override
	protected void onPause() {
		mMapView.onPause();
		super.onPause();
	}

	@Override
	protected void onResume() {
		mMapView.onResume();
		super.onResume();
	}

	@Override
	protected void onDestroy() {
		mMapView.destroy();
		super.onDestroy();
	}

	@Override
	protected void onSaveInstanceState(Bundle outState) {
		super.onSaveInstanceState(outState);
		mMapView.onSaveInstanceState(outState);

	}

	@Override
	protected void onRestoreInstanceState(Bundle savedInstanceState) {
		super.onRestoreInstanceState(savedInstanceState);
		mMapView.onRestoreInstanceState(savedInstanceState);
	}
}

布局XMl:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/btn_clear"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="10dp"
            android:layout_weight="1.0"
            android:background="@drawable/button_style"
            android:text="清除(clear)" />

        <Button
            android:id="@+id/btn_reset"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="10dp"
            android:layout_weight="1.0"
            android:background="@drawable/button_style"
            android:text="重置(reset)" />
    </LinearLayout>

    <com.baidu.mapapi.map.MapView
        android:id="@+id/bmapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clickable="true" />

</LinearLayout>

Manifest配置跟前面一样。

附上图片效果:



 


    
[3] xcode 模拟器没法正常运行的解决
    来源: 互联网  发布时间: 2014-02-18
xcode 模拟器无法正常运行的解决

原始地址:xcode 模拟器无法正常运行的解决

出现情况:xcode build 模拟器后,第一次模拟器打开,停在launch image处,无任何debug信息。关闭模拟器重新build,Run和Stop按钮无法点击,或者要么显示Running XX on iPhone 6.1 simulator。

现有几种可能的解决方式:

一、模拟器假死

1.删除模拟器中的相应的app,重启xcode和模拟器。


二、armv6

参见http://blog.csdn.net/longjuioo/article/details/8501811


三、hosts文件修改过(我遇到的)

参考这里

打开finder,前往文件夹,/private/etc/hosts






    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3