
iOS开发
文章平均质量分 52
彼时莺飞
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
应用程序的生命周期
1、一个应用程序的结构在应用启动阶段,UIApplicationMain函数设置几个关键对象开始运行程序。iOS应用程序的核心是促进应用中系统和其他对象的交互的UIApplication对象。iOS使用model-view-controller模式,将数据和业务逻辑从可视化视图中分离出来,使应用可以运行在不同尺寸的屏幕上。UIApplication object:管理事件循环和原创 2015-01-04 18:33:10 · 736 阅读 · 0 评论 -
core Animation学习笔记
最近在学习core Animation,//路径曲线 UIBezierPath *movePath = [UIBezierPathbezierPath]; [movePath moveToPoint:fromPoint]; CGPoint toPoint = CGPointMake(300,460); [movePath addQuadC原创 2014-05-29 18:22:33 · 1160 阅读 · 0 评论 -
IOS ARC模式下释放ViewController的内存
最近在做SDK时客户提出了一个要求,就是原创 2014-05-14 14:27:27 · 1650 阅读 · 0 评论 -
iOS的Url中特殊字符的转码处理
今天在写代码时原创 2014-04-09 18:50:22 · 2027 阅读 · 0 评论 -
IOS计算字符串的长度和宽度
+ (CGSize ) width:(CGFloat)width heigth:(CGFloat)heigth content:(NSString *)content fontSize:(UIFont*)fontSize{ CGSize maxSize=CGSizeMake(width, heigth); CGSize contentSize=[content sizeWithF原创 2014-04-03 19:10:26 · 1432 阅读 · 0 评论 -
IOS中pagecontrol颜色设置
[self.PageControlsetPageIndicatorTintColor:[UIColorcolorWithHexString:@"#cccccc"alpha:1.0f]]; [self.PageControlsetCurrentPageIndicatorTintColor:[UIColorcolorWithHexString:@"#0088dd"al原创 2014-04-04 12:46:30 · 1184 阅读 · 0 评论 -
ios自定义星级控件
#import @interface CustomStar : UIView- (id)initWithFrame:(CGRect)frame starCount:(int)count normalImage:(NSString *)normal selectedImage:(NSString* )selected starW:(float)wight starH:(float)height原创 2014-03-21 19:17:25 · 909 阅读 · 0 评论 -
iOS复制字符串到剪贴板
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; pasteboard.string = label.text;pasteboard.string; pasteboard.image; pasteboard.URL; pasteboard.color; pasteb原创 2014-04-01 10:19:25 · 781 阅读 · 0 评论 -
iOS中计算中英混排的label宽度问题
今天在写代码时遇到一个问题,就是需要在不固定长度的label后边添加一个图标,平时计算label的宽度都会用到:CGSize contentSize=[str sizeWithFont:Label.fontconstrainedToSize:maxSize lineBreakMode:NSLineBreakByWordWrapping];今天在使用的时候发现了问题,就是如果la原创 2014-03-31 18:21:16 · 1819 阅读 · 0 评论 -
ios扇形动画菜单
计算扇形点的坐标://计算扇形坐标- (NSMutableArray *)getXWithTanAngle:(double)tanAngle { double x; double y; NSMutableArray *locationArray = [[NSMutableArray alloc]init]; x = r / (sqrt(1 + tanAngle原创 2014-07-14 14:48:02 · 3660 阅读 · 1 评论 -
iOS中的lazyload
#pragma lazyLoading- (NSMutableArray *)dataArray { if (_dataArray == nil) { _dataArray = [[NSMutableArray alloc] init]; } return _dataArray;}原创 2014-08-12 15:28:57 · 453 阅读 · 0 评论 -
UIWindow
继承关系NSObjectUIResponderUIViewUIWindow一、配置UIWindow1、windowlevei:@property(nonatomic) UIWindowLevel windowLevel默认值为0.02、screen:@property(nonatomic, retain) UIScreen *screenwindow当前显示的的原创 2014-12-22 17:20:35 · 1128 阅读 · 0 评论 -
iOS国家城市选择器 读取本地json文件
读取本地json文件中的国家和城市信息,显示到pickerview上。原创 2014-11-26 16:56:52 · 3079 阅读 · 0 评论 -
iOS扩展navgation,支持锁定旋转方向
//扩展navgation,支持锁定旋转方向@implementation UINavigationController (Rotation_IOS6)- (BOOL)shouldAutorotate { return [[self.viewControllers lastObject] shouldAutorotate]; }- (NSUInteger)sup原创 2014-10-16 12:21:13 · 652 阅读 · 0 评论 -
iOS屏幕旋转相关
supportedInterfaceOrientations设备支持方向- (NSUInteger)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft;}原创 2014-10-16 12:23:44 · 644 阅读 · 0 评论 -
iOS批量上传图片(多图上传)
由于iOS无法通过html表单来上传图片,因此想要上传图片,必须实现http请求,而不能像其他语言那样通过html表单的post就能上传,做单图上传时参考网上的例子可以实现,但是发现网上的例子不支持多张上传,所以自己仿照单图的格式写了一个多图上传的。其实只要格式拼接正确就可以实现多图上传的功能。.h文件实现#import @interface PicUpload : NSObject原创 2014-02-21 22:39:34 · 5825 阅读 · 3 评论 -
ios uitextview禁用放大镜,拷贝,全选等操作
通过以下方法来禁用相关操作通过禁用禁用放大镜原创 2014-10-28 17:45:21 · 8696 阅读 · 1 评论 -
iOS UIPickerView
* NSObject * UIResponder * UIView * UIPickerViewUIPickerView只有三个高度, heights for UIPickerView (162.0, 180.0 and 216.0)- (NSInteger)numberOfRowsInComponent:(NSInteger)component 组件的行数,默认原创 2014-09-25 11:11:13 · 975 阅读 · 0 评论 -
iOS检测设备类型
/** * 检测设备类型 * * @param name @"iPhone","iPod",@"iPad" * * @return YES OR NO */+ (BOOL)checkDevice:(NSString*)name{ NSString* deviceType = [UIDevice currentDevice].model; NSRang原创 2014-09-16 18:39:02 · 685 阅读 · 0 评论 -
MPMoviePlayerController和MPMoviePlayerVievController
//由于程序的设计需求,要求实现类似广告banner展示的视频播放效果,也就是用户不能控制视频的播放和停止,播放器将循环播放指定的视频 playerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:@"http://sm.domob.cn/ugc/151原创 2014-04-14 16:07:09 · 856 阅读 · 0 评论 -
ios开发中的基本设计模式
(一)代理模式应用场景:当一个类的某些功能需要由别的类来实现,但是又不确定具体会是哪个类实现。优势:解耦合敏捷原则:开放-封闭原则实例:tableview的 数据源delegate,通过和protocol的配合,完成委托诉求。列表row个数delegate自定义的delegate(二)观察者模式应用场景:一般为model层对,controller和view进行的转载 2014-03-06 09:58:24 · 604 阅读 · 0 评论 -
ios7中pickerview添加背景图
UIImageView *imageView1 = [[UIImageView alloc] initWithFrame:[_datePicker bounds]]; imageView1.image = [UIImage imageNamed:@"kuang.png"]; [_datePicker addSubview:imageView1]; [_datePicker原创 2014-03-12 18:14:40 · 1415 阅读 · 0 评论 -
百度地图使用(二)自定义大头针和弹出气泡
// 根据anntation生成对应的View- (BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id )annotation{ NSString *AnnotationViewID = [NSString stringWithFormat:@"renameMark%d",i];原创 2014-02-25 09:21:20 · 3659 阅读 · 0 评论 -
iOS输入数字验证
验证输入值为0~9之间一个数字//数字验证-(BOOL) isNumber:(NSString*)number { NSString *numberRegex = @"[0-9]"; NSPredicate *numberTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", numberRegex];原创 2014-02-17 17:54:10 · 909 阅读 · 0 评论 -
iOS自定义带有placeholder的TextView(多行)
.h定义:#import @interface CloverText : UITextView @property(nonatomic,strong) UITextView *TV;- (id)initWithFrame:(CGRect)frame placeholder:(NSString *)placeholder;@end.m定义:#import "Cl原创 2014-02-27 18:22:09 · 1403 阅读 · 0 评论 -
iOS隐藏键盘————给iOS键盘添加收起(隐藏)按钮
由于ios键盘不像安卓的一样有自带的隐藏按键,虽然有时候可以点击空白处隐藏,但是当页面布局复杂的时候也不太方便使用,所以,可以考虑在键盘上方添加一个隐藏按钮,并使按钮可以随着键盘高度的变化而自动调整。以下是代码:主要是通过添加一个toolbar,上面的按钮可以使用系统的,也可以自定义。UIToolbar * topView = [[UIToolbar alloc]initWithFrame原创 2014-02-13 12:55:55 · 3917 阅读 · 3 评论 -
iOS--UITextView的高度自适应
使用textview的代理方法:[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(UITextViewTextDidChange:) name:UITextViewTextDidChangeNotification object:nil];在方法实现里添加改变高度的代码://当输入的文字原创 2014-02-19 14:03:39 · 1723 阅读 · 0 评论 -
iOS验证手机号码
验证手机号码的正确性//验证手机号- (BOOL)isMobileNumber:(NSString *)mobileNum{ if ([mobileNum length] == 0) { UIAlertView* alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"提原创 2014-02-14 12:51:05 · 828 阅读 · 0 评论 -
iOS邮箱验证
邮箱格式正确性验证:-(BOOL) isEmailAddress:(NSString*)email { NSString *emailRegex = @"^\\w+((\\-\\w+)|(\\.\\w+))*@[A-Za-z0-9]+((\\.|\\-)[A-Za-z0-9]+)*.[A-Za-z0-9]+$"; NSPredicate *emailTest =原创 2014-02-14 09:10:22 · 756 阅读 · 0 评论 -
iOS自定义tabbar,可以隐藏
通常在写项目的时候很少直接使用系统的tabbar,因为隐藏或者修改显示风格很麻烦,所以会使用自定义的。在tabbar.h中添加代码#import @interface MyTabBar : UITabBarController@property (strong, nonatomic) UIView *tabBarView;- (void)setTabWithArray:(NSAr原创 2014-02-25 09:52:50 · 1119 阅读 · 0 评论 -
iOS代理与协议
1、协议是一组通讯协议,一般用作两个类之间的通信。2、协议声明了一组所有类对象都可以实现的接口。3、协议不是类,用@protocol关键字声明一个协议,其中,有两个预编译指令,@optional:表示可以选择实现的方法,@required:表示必须实现的方法。4、与协议有关的两个对象,代理者和委托者,委托者委托代理者实现某些方法。5、代理,实现协议的方法。6、委托者,用自己的方原创 2014-02-26 21:13:02 · 874 阅读 · 0 评论 -
iOS应用调用手机发送短信和拨打电话
iOS应用调用手机发送短信-(void)messageShare{ Class messageClass=(NSClassFromString(@"MFMessageComposeViewController")); if (messageClass !=nil) { if ([messageClass canSendText]) {原创 2014-02-15 09:09:34 · 807 阅读 · 0 评论 -
iOS图片合成————(拍照换发)
一个简单和换发小程序,可以实现拍照,移动发型,放大缩小发型。.h中实现:#import @interface ChangeHairVC : UIViewController@property (strong, nonatomic) IBOutlet UIView *photoView;@property (weak, nonatomic) IBOutlet UIImageView原创 2014-02-28 17:26:25 · 1928 阅读 · 0 评论 -
iOS遍历系统字体
NSArray *familyNames =[UIFont familyNames]; for( NSString*familyName in familyNames ){ printf( "Family: %s \n", [familyName UTF8String] ); NSArray *fontNames = [UIFont fontNamesFor原创 2014-03-04 13:38:07 · 1211 阅读 · 0 评论 -
iOS截取图片
UIGraphicsBeginImageContext(self.tableView.tableHeaderView.frame.size); //可以是view,scrollView,tableview的herderview,但是不能是tableview CGContextRef context = UIGraphicsGetCurrentContext(); [self.tab原创 2014-03-04 18:17:09 · 868 阅读 · 0 评论 -
iOS中的KVO
KVO,即:Key-Value Observing,它提供一种机制,当指定的对象的属性被修改后,则对象就会接受到通知。简单的说就是每次指定的被观察的对象的属性被修改后,KVO就会自动通知相应的观察者了。这种观察-被观察模型适用于这样的情况,比方说根据A(数据类)的某个属性值变化,B(view类)中的某个属性做出相应变化。对于推崇MVC的cocoa而言,kvo应用的地方非常广泛。(这样的机制听起来类原创 2014-03-03 14:58:54 · 637 阅读 · 0 评论 -
iOS星级评定效果
一个非常简单的DEMO,,实现点击按钮改变星级的效果//点击按钮触发事件- (IBAction)matchDescription:(UIButton *)sender { for(UIButton *tmpView in [self.view subviews]) { if(tmpView.tag >= 0 && tmpView.tag <=原创 2014-02-20 13:31:20 · 660 阅读 · 0 评论 -
iOS的单态(singleton)设计模式
如果你准备写一个类,希望保证只有一个实例存在,同时可以得到这个特定实例提供服务的入口,那么可以使用单态设计模式。单态模式在Java、C++中很常用,在Cocoa里,也可以实现。由于自己设计单态模式存在一定风险,主要是考虑到可能在多线程情况下会出现的问题,因此苹果官方建议使用以下方式来实现单态模式:static MyGizmoClass *sharedGizmoManager转载 2014-03-03 09:15:28 · 701 阅读 · 0 评论 -
OC字符串操作
/--------操作字符串--NSString(静态字符串)--------------------- NSString *Beijing= @"北京欢迎您"; //字符串的声明 NSString *log=@"北京欢迎您a"; //[NSString stringWithFormat:@"I am '%@'",Beijing]; //字符串格式转载 2014-03-02 14:15:44 · 889 阅读 · 0 评论 -
iOS图片处理(一)————调用系统相机和相册获取图片,给相机添加自定义覆盖物
首先,照相或从相册选择照片需要使用UIImagePickerController,使用时需要添加两个代理#import @interface ViewController : UIViewController@property (weak, nonatomic) IBOutlet UIScrollView *imageScroll;@property (weak, nonatomic)原创 2014-02-18 12:47:38 · 7397 阅读 · 0 评论