
我和ios有个约定
文章平均质量分 53
lzylzy1991
这个作者很懒,什么都没留下…
展开
-
我和ios有个约定 (2)
在OC中 char 只表示单个字符,如果在O-C中使用字符串,可以使用NSString类型,就是之前我们见过的@""部分。列如: 1:char charVar = 'N'; 2: NSLog(@"integer var = %i", integerVar);原创 2015-05-31 09:43:54 · 269 阅读 · 0 评论 -
我和ios有个约定
我和object-c的初次见面原创 2015-05-22 09:27:11 · 374 阅读 · 0 评论 -
Objective-C 中,id 类型是一个独特的数据类型
在Objective-C 中,id 类型是一个独特的数据类型。在概念上,类似Java 的Object 类,可以转换为任何数据类型。换句话说,id 类型的变量可以存放任何数据类型的对象。在内部处理上,这种类型被定义为指向对象的指针,实际上是一个指向这种对象的实例变量的指针。例如,下面定义了一个id类型的变量和返回一个id类型的方法:id anObject; - (id) newObject转载 2015-05-22 09:50:23 · 439 阅读 · 0 评论 -
字符串倒转
NSString * str =@"I am so bad man"; NSArray *arry = [strcomponentsSeparatedByString:@" "]; NSMutableArray *mutablearry = [[NSMutableArrayalloc]init];原创 2015-06-06 17:02:19 · 403 阅读 · 0 评论 -
字典的相关操作
NSDictionary *dict = [[NSDictionaryalloc]initWithObjectsAndKeys:@"one",@"1",@"two",@"2",@"three",@"3",nil]; NSLog(@"1---%@",dict); // 字典的遍历 NSEnumerator *原创 2015-06-06 17:35:01 · 345 阅读 · 0 评论 -
object-c(oc)内存管理机制详解
.内存的创建和释放 让我们以Object-c世界中最最简单的申请内存方式展开,谈谈关于一个对象的生命周期。首先创建一个对象:123//“ClassName”是任何你想写的类名,比如NSString NSArray等一切随意id testObject = [[ClassName alloc] init];注: alloc原创 2015-06-09 14:43:16 · 400 阅读 · 0 评论 -
OC 三种单列写法
staticThememanger *thememanger;+(id )sharedmange{ if (thememanger ==nil) { thememanger = [[self alloc ]init]; }原创 2015-06-11 16:26:32 · 426 阅读 · 0 评论 -
oc copy
//// main.m// Copy//// Created by liyang on 15-6-12.// Copyright (c) 2015年 liyang. All rights reserved.//#import #import "Goodstudent.h"#import "student.h"#pragma mark 字符copy#pragma mark 字符copy (深拷贝)v原创 2015-06-12 21:42:11 · 280 阅读 · 0 评论 -
UILabel设置多种字体、颜色
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Using NSAttributed String,try your best to test attributed string text"]; [str addAttribute:NSForegroundColorAttr转载 2015-07-26 15:07:46 · 334 阅读 · 0 评论 -
iphone开发必知点之--app图标设置
一、应用图标ios3.2之前不支持在Info.plist文件里指定图标,需要遵循苹果图标命名规范,如下Icon.png 57x57 iphone 应用图标Icon@2x.png 114x114 iphone(Retina显示屏) 应用图标Icon-72.png 72x72 ipad转载 2015-07-27 10:34:51 · 560 阅读 · 0 评论 -
视图跳转按钮
#define NAV_LEFT_MENU_MARGIN -23#define NAV_RIGHT_MENU_MARGIN 25- (void)defaultLeftBackButton { UIBarButtonItem *leftBarItem = nil; leftBarItem = [SaikeBarButtonItem itemWidth:60原创 2015-08-25 16:47:04 · 312 阅读 · 0 评论 -
IOS导航栏的使用方法
本文是使用纯代码实现一个导航栏的效果。单击按钮并且产生事件。基本思路是:1.创建一个导航栏(UINavigationBar对象)2.创建一个导航栏集合(UINavigationItem对象)3.创建一个左边按钮、一个右边按钮(UIBarButtonItem对象),并实现对应的事件方法4.将导航栏集合添加到导航栏中,设置动画关闭5.把左右两个按钮添加到导航栏集合中去6.在视图转载 2015-08-25 17:43:31 · 332 阅读 · 0 评论 -
iOS开发系列--视图切换
概述在iOS开发中视图的切换是很频繁的,独立的视图应用在实际开发过程中并不常见,除非你的应用足够简单。在iOS开发中常用的视图切换有三种,今天我们将一一介绍:UITabBarControllerUINavigationController模态窗口UITabBarControlleriOS三种视图切换的原理各不相同:UITabBarController:以平行的方转载 2015-07-30 10:50:32 · 333 阅读 · 0 评论 -
修改navigationBar title的背景颜色
这个方法在iOS5以后可以这样用navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor yellowColor] forKey:UITextAttributeTextColor]; 通过以下key值修改起属性UITextAttribu原创 2015-08-26 16:31:08 · 335 阅读 · 0 评论 -
调整UILabel行高间距
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 320, 200)]; [label setBackgroundColor:[UIColor blackColor]]; [label setTextColor:[UIColor whiteColor]]; [label setNumb转载 2015-08-02 13:58:33 · 378 阅读 · 0 评论 -
设置UIlable字体的行距 字体大小 颜色
NSMutableAttributedString *strMutable = [[NSMutableAttributedString alloc]initWithString:strtext]; // 行间距 NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] i原创 2015-08-03 09:41:20 · 506 阅读 · 0 评论 -
IOS成长之路-导航栏的实现
创建这样一个项目:在Model中创建一个简单的 view 界面,而 ViewController 类是一个表格的界面创建表格的界面:第一步:第二步:注意: Subclass of 的选项要选择 UITableViewController然后下一步,最后点击create就可以了=-=-=-=-=-=-=-转载 2015-08-03 22:05:30 · 304 阅读 · 0 评论 -
提示框第三方库 MBProgressHUD
MBProgressHUD是一个开源项目,实现了很多种样式的提示框,使用上简单、方便,并且可以对显示的内容进行自定义,功能很强大,很多项目中都有使用到。到GitHub上可以下载到项目源码https://github.com/jdg/MBProgressHUD,下载下来后直接把MBProgressHUD.h和MBProgressHUD.m拖入工程中就行,别忘了选择拷贝到工程。完了在需要使用的地方导入转载 2015-07-23 12:22:05 · 388 阅读 · 0 评论 -
SQLite3(创建、插入、查询、更新数据库和表)
众所周知,sqlite3是ios数据存储其一,具体优点和缺点,我就不再赘述,请大家搜索之。一、必备条件在ios项目中使用sqlite需要添加 libsqlite3.dylib 库二、简单介绍常用方法sqlite3 *db, 数据库句柄,跟文件句柄FILE很类似sqlite3_stmt *stmt, 这个相当于ODBC转载 2015-07-24 18:19:03 · 1810 阅读 · 0 评论 -
iOS学习之 plist文件的读写
在做iOS开发时,经常用到到plist文件, 那plist文件是什么呢? 它全名是:Property List,属性列表文件,它是一种用来存储串行化后的对象的文件。属性列表文件的扩展名为.plist ,因此通常被称为 plist文件。文件是xml格式的。Plist文件通常用于储存用户设置,也可以用于存储捆绑的信息我们创建一个项目来学习plist文件的读写。转载 2015-07-24 18:14:13 · 300 阅读 · 0 评论 -
iOS开发之iOS界面UI
1、UILabel 1 NSString *str = @"字符串大小"; 2 UIFont *font = [UIFont fontWithName:@"Arial" size:50.0f]; 3 CGSize size = CGSizeMake(320, 2000); 4 UILabel *label = [[UILabel alloc] initWithFrame:CGRe转载 2015-07-23 13:40:20 · 396 阅读 · 0 评论 -
navigationbar右侧加两个自定义按钮
UIView *rightBarView = [[UIViewalloc]initWithFrame:CGRectMake(0,0,60, 31)]; UIButton *phonebutton = [UIButtonbuttonWithType:UIButtonTypeCustom]; phonebutton.frame=CGRectMake(0,5,25原创 2015-09-01 18:45:00 · 525 阅读 · 0 评论 -
UIAlertView 使用及按钮响应事件
-(void)addLable{ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认",nil]; alert.alertViewStyle = UIAlertV原创 2015-09-09 12:53:07 · 603 阅读 · 0 评论 -
UISearchBar 背景 边框设置
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(10, 3, SWidth-20, 30)]; searchBar.placeholder = @"请输入关键字";// searchBar.barTintColor = [UIColor greenColor]; searchBar.backgroundI原创 2015-09-09 15:21:49 · 1101 阅读 · 0 评论 -
ios 读取图片
一.读取图片1.从资源(resource)读取[cpp] viewplaincopyprint?UIImage* image=[UIImage imageNamed:@"1.jpg"]; 2.从网络读取[cpp] viewplaincopyprint?NSURL *url=[NSURL U转载 2015-09-15 15:25:47 · 396 阅读 · 0 评论 -
NSString拼接字符串
NSString* string; // 结果字符串02NSString* string1, string2; //已存在的字符串,需要将string1和string2连接起来03 04//方法1.05strin转载 2015-09-16 14:13:15 · 559 阅读 · 0 评论 -
修改IOS中UISearchBar的取消按钮背景、搜索内容输入文本框背景和UISearchBar的背景
1、添加UISearchBar到父View _searchBar = [[UISearchBar alloc]init]; _searchBar.frame = CGRectMake(0, 0, self.view.frame.size.width, kSeachBarH); _searchBar.autoresizingMask = UIViewAutoresizingFlexibleWid转载 2015-11-04 19:49:48 · 259 阅读 · 0 评论 -
自定义alertView
自定义alertView,继承自UIView,可以在消息区域添加子视图:addCustomerSubview标题可以有图片+文字构成, 只支持两个按钮操作// - 在需要alert的控制器调用 alertView show 方法[objc] view plaincopyCustomAlertView *alertView = [[CustomAlertV转载 2015-09-18 08:40:26 · 305 阅读 · 0 评论 -
获取图片名
__block NSString *picName = @" " ; //获取图片名 ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset) { ALAssetRepresentation *representation = [myasset defaultRep原创 2015-09-17 14:19:09 · 304 阅读 · 0 评论 -
设置 UISearchBar 输入字体颜色 和 默认字体颜色
UISearchBar *searchBar = [[UISearchBaralloc]initWithFrame:CGRectMake(0,0,210, 44)]; // Get the instance of the UITextField of the search bar UITextField *searchField = [searchBar valueF转载 2015-11-09 11:54:38 · 400 阅读 · 0 评论 -
禁止uiscrollview垂直方向滚动,只允许水平方向滚动;或只允许垂直方向滚动
禁止UIScrollView垂直方向滚动,只允许水平方向滚动scrollview.contentSize = CGSizeMake(你要的长度, 0); 禁止UIScrollView水平方向滚动,只允许垂直方向滚动scrollview.contentSize = CGSizeMake(0, 你要的宽度); 在UIScrollView的SubView里面弹出一转载 2015-11-09 15:05:41 · 302 阅读 · 0 评论 -
iOS中关于设置UIButton文字和图标对齐格式的问题
在设置UIButton文字和图标对齐方式的时候,需要注意:setTitleEdgeInsets和setImageEdgeInsets方法只对通过setTitle和setImage方法设置的文字和图片有效。很多人错将setBackgroundImage当成setImage使用,结果看到了一个图标被作为背景图片拉伸了。之后任怎么设置setImageEdgeInsets都看不到效果。 下转载 2015-11-09 16:00:34 · 565 阅读 · 0 评论 -
UItextField 一键删除小按钮
self.userNameTextfield.clearsOnBeginEditing = NO;self.userNameTextfield.clearButtonMode = UITextFieldViewModeWhileEditing;转载 2015-11-12 18:53:30 · 5512 阅读 · 0 评论 -
UITableView分割线式样 与 颜色设置
self.userInfoTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;self.userInfoTableView.separatorColor = RGB(119, 119, 119, 1);转载 2015-11-12 17:15:44 · 270 阅读 · 0 评论 -
iOS 对plist增改操作
这篇文章是自己通过实践获取,在网上查过很多资料,也走了不上的弯路,由于刚开始学子不久,只是把自己遇到的问题贡献给大家一,创建文件 //获取路径对象 NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); //获转载 2015-11-13 19:21:54 · 233 阅读 · 0 评论 -
UIlable 适应字体大小
UILabel *shopAddressLabel = [[UILabel alloc]init]; //]WithFrame:CGRectMake(70, 90, SCREEN_WIDTH-80,LABEL_HEIGHT_30)]; shopAddressLabel.font = [UIFont systemFontOfSize:[kFontSize12 floatValue]];原创 2015-11-17 14:28:00 · 302 阅读 · 0 评论 -
IOS中输入框被软键盘遮挡的解决办法
//开始编辑输入框的时候,软键盘出现,执行此事件-(void)textFieldDidBeginEditing:(UITextField *)textField{ CGRect frame = textField.frame; int offset = frame.origin.y + 32 - (self.view.frame.size.height - 216.0)转载 2015-11-22 19:27:23 · 304 阅读 · 0 评论 -
UIImageView 圆形
self.image.layer.masksToBounds=YES; self.image.layer.cornerRadius=27.0; //最重要的是这个地方要设成imgview高的一半原创 2015-11-12 20:23:41 · 296 阅读 · 0 评论 -
ios 防止按钮快速点击造成多次响应的避免方法。
有时候有些操作是防止用户在一次响应结束中再响应下一个。但有些测试用户就要猛点,狂点。像这种恶意就要进行防止。当然有些异步操作时,可以在调用前enable 掉。等CallBACK 后再enable起来。过程中按钮是不能点的。1、可以使用:- (void) timeEnough{ UIButton *btn=(UIButton*)[self.view viewWithTag:3转载 2015-12-28 19:40:13 · 934 阅读 · 0 评论 -
ios 类型转换
NSString *tempA = @"123"; NSString *tempB = @"456";1,字符串拼接 NSString *newString = [NSString stringWithFormat:@"%@%@",tempA,tempB];2,字符转intint intString = [newString intValue];3,int转字符转载 2015-12-14 09:50:01 · 323 阅读 · 0 评论