- 博客(22)
- 收藏
- 关注
原创 设置图片大小和截屏
-(UIImage*)scaleToSize:(UIImage*)img size:(CGSize)size { // 创建一个bitmap的context // 并把它设置成为当前正在使用的context UIGraphicsBeginImageContext(size); // 绘制改变大小的图片 [img drawInRect:
2013-08-23 20:22:41 1067
原创 万能公式,想得到什么数字就能得到什么数字
NSString *string = @"测试sting14fkj测试5"; NSMutableArray *mutArr = [[NSMutableArray alloc] init]; for (int i = 0; i<string.length; i++) { NSString *instanceStr = [string sub
2013-06-13 09:39:17 694
原创 UIView 那些事
UILabel * nameLabel = [[UILabel alloc]init]; //定位label(x,y,长,高) nameLabel.frame = CGRectMake(10, 100, 100, 30); nameLabel.text = @"Ios30班"; nameLabel.textColor = [UIColor redColor];//设
2012-08-16 14:31:52 305
原创 同步 异步请求
//新建一个URL NSURL *url=[NSURL URLWithString:@"http://api.hudong.com/iphonexml.do?type=focus-c"]; //创建一个GET请求 cachePolicy:缓存 NSURLRequestReloadRevalidatingCacheData :忽略缓存数据
2012-08-16 12:20:26 545
原创 创建文件 大合集
//查找文件路径的函数 NSString *path= [[NSBundle mainBundle]pathForResource:@"student" ofType:@"txt"]; NSError *error=nil; //stringWithContentsOfFile 是读取 指定路径里的内容 NSUTF8StringEncoding:是对文本编码的
2012-08-16 12:18:00 314
原创 监听 通知
//单例方法 访问 //通知名字 [[NSNotificationCenter defaultCenter] postNotificationName:@"TOBTV" object:self];//接受中心[[NSNotificationCenter defaultCenter]addObserver:sel
2012-08-16 11:57:45 300
原创 NSString 字典 作业
//1.现有如下定义的字符串: NSMutableString * str=@“iphoneAndroid”,能不能对该字符串进行修改,如果能,请输出删除Android后的新字符串。 NSMutableString *str=[NSMutableString stringWithCapacity:2];//创建一个可变的字符串 [str appendString:@"iphoneA
2012-08-16 11:51:58 472
原创 查找文件路径
//查找文件path:路径。 bundle:捆绑 mainBundle:主要包 pathForResource:路径是 ofType:类型//注意本地是initWithContentsOfFile 网络的是initWithContentsOfURL NSString *path=[[NSBundle mainBundle]pathForResource:@"file"
2012-08-16 11:43:55 562
原创 字典 可变字典 大杂烩
//不可变字典 Student *s7=[[Student alloc]initWithName:@"jack"]; NSDictionary *dic=[[NSDictionary alloc]initWithObjectsAndKeys:s7,@"jack",@"26",@"age", nil]; NSString* str15=[dic o
2012-08-16 11:36:22 287
原创 NSArray 大杂烩
//声明一个数组 NSString *strOne=@"lxd"; NSString *strTow=@"abc"; NSString *strTree=@"def"; NSArray *strArray=[[NSArray alloc] initWithObjects:strOne,strTow,strTree, nil];//数组初始化方法 // 查看数
2012-08-16 11:15:07 300
原创 NSString 大杂烩
最简单的创建方法NSString *str=[NSString alloc]initWithString:@"lxd"];把int型 格式化成字符串int i=9;NSString *str=[NSString alloc]initWithFormat:@"%d",i];静态方法创建字符串NSString *str=[NSString stringWithFormat:@"
2012-08-16 11:11:00 294
原创 单例
单纯从编程的角度出发,单例可以节省不必要的内存开销屏蔽对象创建的复杂性创建单例+(AppStatus *)shareAppInstance{ if (shareAppStatus == nil) { shareAppStatus = [[AppStatus alloc] init]; } return shareAppStatus
2012-08-16 10:29:57 235
原创 label textField button 一些用法
///UILabelUILabel *nameLabel=[UIlabel alloc]init];//初始化nameLabel.frame=CGRectMake(10,100,100,30);//定义坐标和大小X,Y,W,H;nameLabel.text=@"IOS30班";//给LABEL 赋值nameLabel.textColor=[UIColor redColor];//文本的颜
2012-08-14 10:35:04 558
原创 UIView中插入子视图
UIView *redView=[[UIView alloc]initWithFrame:CGRectMake(100, 100, 50, 50)]; redView.backgroundColor=[UIColor redColor]; [self.view addSubview:redView]; [redView release]; UIV
2012-08-14 10:34:35 645
原创 改变视图的放大 缩小
- (void)loadView{ //必须先初始化一个底层的 View UIView *aView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; self.view = aView; [aView release]; UIView *twoView = [[UIView
2012-08-14 10:34:06 505
原创 Quartz 画笔
- (id)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if (self) { _lineArray=[NSMutableArray array];//静态方法初始化 [_lineArray retain];//因为是静态方法初始化了 只要出这个函数就会释放 所以
2012-08-14 10:33:35 452
原创 UISegmentedControl and 动画
- (void)loadView{ //UISegmentedControl self.view=[[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 480 )]autorelease]; self.view.backgroundColor=[UIColor blueColor];
2012-08-14 10:33:06 580
原创 手势,抖动
- (void)loadView{ self.view=[[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)] autorelease]; self.view.backgroundColor=[UIColor whiteColor]; _imagView=[[UIImageView alloc
2012-08-14 10:32:34 607
原创 UIScrollView 基本用法
- (void)loadView{ self.view=[[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)]autorelease]; self.title=self.detailTitle; /* textField=[[UITextField alloc]initWithFram
2012-08-14 10:31:47 634
原创 解析(xml,json)
第一步;导入解析文件配置XML :header search 添加 /usr/include/libxml2 如果报错前面加$(SDKROOT)导入libxml2.dylib 框架Other linker flags 添加:-lxml2 //创建XML 读取本地内容 NSString *path=[[NSBundle mainBundle] pathForRes
2012-08-14 10:30:26 405
原创 添加警报视图UIAlertView
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"单击了动态按钮" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil]; [alert show];//动画显示弹出警告 [alert release]; UIA
2012-08-12 11:41:33 445
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人