- 博客(42)
- 资源 (12)
- 收藏
- 关注
原创 应用程序的生命周期
1、一个应用程序的结构在应用启动阶段,UIApplicationMain函数设置几个关键对象开始运行程序。iOS应用程序的核心是促进应用中系统和其他对象的交互的UIApplication对象。iOS使用model-view-controller模式,将数据和业务逻辑从可视化视图中分离出来,使应用可以运行在不同尺寸的屏幕上。UIApplication object:管理事件循环和
2015-01-04 18:33:10
715
原创 UIWindow
继承关系NSObjectUIResponderUIViewUIWindow一、配置UIWindow1、windowlevei:@property(nonatomic) UIWindowLevel windowLevel默认值为0.02、screen:@property(nonatomic, retain) UIScreen *screenwindow当前显示的的
2014-12-22 17:20:35
1107
原创 iOS屏幕旋转相关
supportedInterfaceOrientations设备支持方向- (NSUInteger)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft;}
2014-10-16 12:23:44
629
原创 iOS扩展navgation,支持锁定旋转方向
//扩展navgation,支持锁定旋转方向@implementation UINavigationController (Rotation_IOS6)- (BOOL)shouldAutorotate { return [[self.viewControllers lastObject] shouldAutorotate]; }- (NSUInteger)sup
2014-10-16 12:21:13
633
原创 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
955
原创 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
668
原创 iOS中的lazyload
#pragma lazyLoading- (NSMutableArray *)dataArray { if (_dataArray == nil) { _dataArray = [[NSMutableArray alloc] init]; } return _dataArray;}
2014-08-12 15:28:57
440
原创 数据结构复习————单链表在指定位置插入删除元素
//单链表在指定位置插入元素,O(n)ElemType ListInsert_L(LinkList *L , int i , ElemType e){ LinkList p = (LinkList)malloc(sizeof(LNode)); int j = 0; while (p && j < i - 1) { p = p
2014-08-11 14:52:05
1525
原创 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
3630
1
原创 core Animation学习笔记
最近在学习core Animation,//路径曲线 UIBezierPath *movePath = [UIBezierPathbezierPath]; [movePath moveToPoint:fromPoint]; CGPoint toPoint = CGPointMake(300,460); [movePath addQuadC
2014-05-29 18:22:33
1141
原创 MPMoviePlayerController和MPMoviePlayerVievController
//由于程序的设计需求,要求实现类似广告banner展示的视频播放效果,也就是用户不能控制视频的播放和停止,播放器将循环播放指定的视频 playerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:@"http://sm.domob.cn/ugc/151
2014-04-14 16:07:09
846
原创 IOS中pagecontrol颜色设置
[self.PageControlsetPageIndicatorTintColor:[UIColorcolorWithHexString:@"#cccccc"alpha:1.0f]]; [self.PageControlsetCurrentPageIndicatorTintColor:[UIColorcolorWithHexString:@"#0088dd"al
2014-04-04 12:46:30
1165
原创 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
1406
原创 iOS复制字符串到剪贴板
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; pasteboard.string = label.text;pasteboard.string; pasteboard.image; pasteboard.URL; pasteboard.color; pasteb
2014-04-01 10:19:25
758
原创 iOS中计算中英混排的label宽度问题
今天在写代码时遇到一个问题,就是需要在不固定长度的label后边添加一个图标,平时计算label的宽度都会用到:CGSize contentSize=[str sizeWithFont:Label.fontconstrainedToSize:maxSize lineBreakMode:NSLineBreakByWordWrapping];今天在使用的时候发现了问题,就是如果la
2014-03-31 18:21:16
1790
原创 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
897
原创 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
1405
转载 ios开发中的基本设计模式
(一)代理模式应用场景:当一个类的某些功能需要由别的类来实现,但是又不确定具体会是哪个类实现。优势:解耦合敏捷原则:开放-封闭原则实例:tableview的 数据源delegate,通过和protocol的配合,完成委托诉求。列表row个数delegate自定义的delegate(二)观察者模式应用场景:一般为model层对,controller和view进行的
2014-03-06 09:58:24
595
原创 iOS截取图片
UIGraphicsBeginImageContext(self.tableView.tableHeaderView.frame.size); //可以是view,scrollView,tableview的herderview,但是不能是tableview CGContextRef context = UIGraphicsGetCurrentContext(); [self.tab
2014-03-04 18:17:09
856
原创 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
1191
原创 iOS中的KVO
KVO,即:Key-Value Observing,它提供一种机制,当指定的对象的属性被修改后,则对象就会接受到通知。简单的说就是每次指定的被观察的对象的属性被修改后,KVO就会自动通知相应的观察者了。这种观察-被观察模型适用于这样的情况,比方说根据A(数据类)的某个属性值变化,B(view类)中的某个属性做出相应变化。对于推崇MVC的cocoa而言,kvo应用的地方非常广泛。(这样的机制听起来类
2014-03-03 14:58:54
624
转载 iOS的单态(singleton)设计模式
如果你准备写一个类,希望保证只有一个实例存在,同时可以得到这个特定实例提供服务的入口,那么可以使用单态设计模式。单态模式在Java、C++中很常用,在Cocoa里,也可以实现。由于自己设计单态模式存在一定风险,主要是考虑到可能在多线程情况下会出现的问题,因此苹果官方建议使用以下方式来实现单态模式:static MyGizmoClass *sharedGizmoManager
2014-03-03 09:15:28
690
转载 OC字符串操作
/--------操作字符串--NSString(静态字符串)--------------------- NSString *Beijing= @"北京欢迎您"; //字符串的声明 NSString *log=@"北京欢迎您a"; //[NSString stringWithFormat:@"I am '%@'",Beijing]; //字符串格式
2014-03-02 14:15:44
875
原创 iOS图片合成————(拍照换发)
一个简单和换发小程序,可以实现拍照,移动发型,放大缩小发型。.h中实现:#import @interface ChangeHairVC : UIViewController@property (strong, nonatomic) IBOutlet UIView *photoView;@property (weak, nonatomic) IBOutlet UIImageView
2014-02-28 17:26:25
1911
原创 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
1384
原创 iOS代理与协议
1、协议是一组通讯协议,一般用作两个类之间的通信。2、协议声明了一组所有类对象都可以实现的接口。3、协议不是类,用@protocol关键字声明一个协议,其中,有两个预编译指令,@optional:表示可以选择实现的方法,@required:表示必须实现的方法。4、与协议有关的两个对象,代理者和委托者,委托者委托代理者实现某些方法。5、代理,实现协议的方法。6、委托者,用自己的方
2014-02-26 21:13:02
861
原创 iOS自定义tabbar,可以隐藏
通常在写项目的时候很少直接使用系统的tabbar,因为隐藏或者修改显示风格很麻烦,所以会使用自定义的。在tabbar.h中添加代码#import @interface MyTabBar : UITabBarController@property (strong, nonatomic) UIView *tabBarView;- (void)setTabWithArray:(NSAr
2014-02-25 09:52:50
1082
原创 百度地图使用(二)自定义大头针和弹出气泡
// 根据anntation生成对应的View- (BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id )annotation{ NSString *AnnotationViewID = [NSString stringWithFormat:@"renameMark%d",i];
2014-02-25 09:21:20
3641
原创 百度地图使用(一)添加地图
1、首先,根据官方SDK指南,先引入CoreLocation.framework和QuartzCore.framework、OpenGLES.framework、SystemConfiguration.framework、CoreGraphics.framework、security.framework。2、在需要使用百度MapAPI的文件中添加以下代码#import "BMapKit
2014-02-23 15:58:09
953
原创 iOS批量上传图片(多图上传)
由于iOS无法通过html表单来上传图片,因此想要上传图片,必须实现http请求,而不能像其他语言那样通过html表单的post就能上传,做单图上传时参考网上的例子可以实现,但是发现网上的例子不支持多张上传,所以自己仿照单图的格式写了一个多图上传的。其实只要格式拼接正确就可以实现多图上传的功能。.h文件实现#import @interface PicUpload : NSObject
2014-02-21 22:39:34
5793
原创 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
650
原创 iOS--UITextView的高度自适应
使用textview的代理方法:[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(UITextViewTextDidChange:) name:UITextViewTextDidChangeNotification object:nil];在方法实现里添加改变高度的代码://当输入的文字
2014-02-19 14:03:39
1702
原创 iOS图片处理(一)————调用系统相机和相册获取图片,给相机添加自定义覆盖物
首先,照相或从相册选择照片需要使用UIImagePickerController,使用时需要添加两个代理#import @interface ViewController : UIViewController@property (weak, nonatomic) IBOutlet UIScrollView *imageScroll;@property (weak, nonatomic)
2014-02-18 12:47:38
7364
原创 iOS输入数字验证
验证输入值为0~9之间一个数字//数字验证-(BOOL) isNumber:(NSString*)number { NSString *numberRegex = @"[0-9]"; NSPredicate *numberTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", numberRegex];
2014-02-17 17:54:10
890
原创 iOS应用调用手机发送短信和拨打电话
iOS应用调用手机发送短信-(void)messageShare{ Class messageClass=(NSClassFromString(@"MFMessageComposeViewController")); if (messageClass !=nil) { if ([messageClass canSendText]) {
2014-02-15 09:09:34
797
原创 iOS验证手机号码
验证手机号码的正确性//验证手机号- (BOOL)isMobileNumber:(NSString *)mobileNum{ if ([mobileNum length] == 0) { UIAlertView* alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"提
2014-02-14 12:51:05
808
MPMoviePlayerControllerDemo
2014-04-14
iOS中KVCDemo
2014-03-03
iOS多图上传类
2014-02-21
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人