当前位置:  编程技术>移动开发
本页文章导读:
    ▪解决非IE无法使用innerText有关问题        解决非IE无法使用innerText问题 function isIE(){ //判断是否是ie if (window.navigator.userAgent.toString().toLowerCase().indexOf("msie") >=1) return true; else return false; } if(!isIE()){ //firefox.........
    ▪ objective-c根本数据类型之输出格式符        objective-c基本数据类型之输出格式符 基本数据类型 1. int 输出格式符:%i, %d, %o %x, 2. float输出格式符:%f, %e, %g3. double输出格式符:%f, %e, %g 4. char输出格式符:%c 限定符: 1. longlong int: %lilon.........
    ▪ drawRect的简略示例       drawRect的简单示例 头文件:   #import <UIKit/UIKit.h> #include <math.h> static inline double radians(double degrees) { return degrees * M_PI / 180; } #define FontSize 20.0f @interface DrawScreen : UIView { } - (void)draw.........

[1]解决非IE无法使用innerText有关问题
    来源: 互联网  发布时间: 2014-02-18
解决非IE无法使用innerText问题
function   isIE(){ //判断是否是ie
      if   (window.navigator.userAgent.toString().toLowerCase().indexOf("msie") >=1)
        return   true;
      else
        return   false;
}

if(!isIE()){   //firefox   innerText   define
      HTMLElement.prototype.__defineGetter__(           "innerText",
        function(){
          var   anyString   =   "";
          var   childS   =   this.childNodes;
          for(var   i=0;   i <childS.length;   i++)   {
            if(childS[i].nodeType==1)
              anyString   +=   childS[i].tagName=="BR"   ?   '\n'   :   childS[i].innerText;
            else   if(childS[i].nodeType==3)
              anyString   +=   childS[i].nodeValue;
          }
          return   anyString;
        }
      );
      HTMLElement.prototype.__defineSetter__(           "innerText",
        function(sText){
          this.textContent=sText;
        }
      ); 
} 
 

 


    
[2] objective-c根本数据类型之输出格式符
    来源: 互联网  发布时间: 2014-02-18
objective-c基本数据类型之输出格式符

基本数据类型

1. int

输出格式符:%i, %d, %o %x, 

2. float
输出格式符:%f, %e, %g

3. double
输出格式符:%f, %e, %g

4. char

输出格式符:%c

限定符:


1. long
long int: %li
long double: %Lf
形成long int通过在数字后面加L.
long int number = 123324123234123L;

2. long long
long long int: %lli

3. short
short int: %hi

4. unsigned

5. signed

 

它们各自所占的字节数

 

#import <Foundation/Foundation.h>

 

int main (int argc, const char * argv[]) {

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

NSLog(@"The size of an int is: %d bytes.",sizeof(int));

NSLog(@"The size of a short int is: %d bytes.",sizeof(short int));

NSLog(@"The size of a long int is: %d bytes.",sizeof(long int));

NSLog(@"The size of a char is: %d bytes.",sizeof(char));

NSLog(@"The size of a float is: %d bytes.",sizeof(float));

NSLog(@"The size of a double is: %d bytes.",sizeof(double));

NSLog(@"The size of a bool is: %d bytes.",sizeof(bool));

    [pool drain];

    return 0;

}

 

2011-08-21 09:29:16.475 sizeofTest[860:903] The size of an int is: 4 bytes.

2011-08-21 09:29:16.478 sizeofTest[860:903] The size of a short int is: 2 bytes.

2011-08-21 09:29:16.478 sizeofTest[860:903] The size of a long int is: 8 bytes.

2011-08-21 09:29:16.479 sizeofTest[860:903] The size of a char is: 1 bytes.

2011-08-21 09:29:16.479 sizeofTest[860:903] The size of a float is: 4 bytes.

2011-08-21 09:29:16.479 sizeofTest[860:903] The size of a double is: 8 bytes.

2011-08-21 09:29:16.480 sizeofTest[860:903] The size of a bool is: 1 bytes.

logout

 

转自:http://www.cnblogs.com/getsun/archive/2011/08/21/2147618.html


    
[3] drawRect的简略示例
    来源: 互联网  发布时间: 2014-02-18
drawRect的简单示例

头文件:

 

#import <UIKit/UIKit.h>
#include <math.h>

static inline double radians(double degrees) {
	return degrees * M_PI / 180;
}

#define FontSize 20.0f

@interface DrawScreen : UIView {
	
}

- (void)drawTextByString:(NSString *)drawText thePoisition:(CGPoint)point;
- (void)drawPicByImage:(UIImage *)theImage theRect:(CGRect)rect;
- (void)drawTextByQuartz:(CGContextRef)context theText:(const char *)drawtext 
			thePoisition:(CGPoint)point rotateAngle:(float)angle;
- (void)drawPicByQuartz:(CGContextRef)context thePic:(UIImage *)theImage theLocation:(CGRect)rect;

@end

 

实现文件:

 

#import "DrawScreen.h"

@implementation DrawScreen

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor blackColor];
    }
    return self;
}

- (void)drawRect:(CGRect)rect {
	CGContextRef context = UIGraphicsGetCurrentContext();
	CGContextSetFillColorWithColor(context, [UIColor greenColor].CGColor);
	
	//方式一:用NSString的方式画字,用UIImage的方式画图片,坐标原点在左上角
	NSString *textOne = [NSString stringWithFormat:@"iPad"];
	NSString *textTwo = [NSString stringWithFormat:@"iPhone"];
	[self drawTextByString:textOne thePoisition:CGPointMake(50.0f, 260.0f)];
	[self drawTextByString:textTwo thePoisition:CGPointMake(250.0f, 260.0f)];
	UIImage *flagOne = [UIImage imageNamed:@"flag.png"];
	[self drawPicByImage:flagOne theRect:CGRectMake(50.0f, 200.0f, 45.0f, 45.0f)];
	[self drawPicByImage:flagOne theRect:CGRectMake(250.0f, 200.0f, 45.0f, 45.0f)];
	
	//方式二:用Quartz2D的方式画字和图片,坐标原点移动到左下角
	CGContextTranslateCTM(context, 0, self.bounds.size.height);
	CGContextScaleCTM(context, 1, -1);
	UIImage *flagTwo = [UIImage imageNamed:@"location.png"];
	[self drawTextByQuartz:context theText:"Apple" thePoisition:CGPointMake(160.0f, 200.0f) rotateAngle:45.0f];
	[self drawTextByQuartz:context theText:"iPod" thePoisition:CGPointMake(50.0f, 100.0f) rotateAngle:45.0f];
	[self drawTextByQuartz:context theText:"iMac" thePoisition:CGPointMake(250.0f, 100.0f) rotateAngle:45.0f];
	[self drawPicByQuartz:context thePic:flagTwo theLocation:CGRectMake(160.0f, 230.0f, 50.0f, 50.0f)];
	[self drawPicByQuartz:context thePic:flagTwo theLocation:CGRectMake(50.0f, 130.0f, 50.0f, 50.0f)];
	[self drawPicByQuartz:context thePic:flagTwo theLocation:CGRectMake(250.0f, 130.0f, 50.0f, 50.0f)];
}

- (void)dealloc {
    [super dealloc];
}

- (void)drawTextByString:(NSString *)drawText thePoisition:(CGPoint)point {
	//方式一
	[drawText drawAtPoint:point withFont:[UIFont systemFontOfSize:FontSize]];
}

- (void)drawPicByImage:(UIImage *)theImage theRect:(CGRect)rect {
	//方式一
	[theImage drawInRect:rect];
}

- (void)drawTextByQuartz:(CGContextRef)context theText:(const char *)drawtext 
			thePoisition:(CGPoint)point rotateAngle:(float)angle {
	//方式二
	CGContextSelectFont(context, "Helvetica", FontSize, kCGEncodingMacRoman);
	CGContextSetTextDrawingMode(context, kCGTextFill);
	CGAffineTransform myTextTransform = CGAffineTransformMakeRotation(radians(angle)); 
	CGContextSetTextMatrix (context, myTextTransform);
	CGContextShowTextAtPoint(context, point.x, point.y, drawtext, strlen(drawtext));
}

- (void)drawPicByQuartz:(CGContextRef)context thePic:(UIImage *)theImage theLocation:(CGRect)rect {
	//方式二
	CGContextDrawImage(context, rect, theImage.CGImage);
}

@end

 

示例图:



    
最新技术文章:
▪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