摘要: imfong.com新博客采用jekyll+Github搭建,欢迎访问. 阅读全文
posted @ 2015-09-14 21:31 Maxfong 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 需求很简单,通过UIViewController.view内的任意控件获取当前UIViewController;立马开写:/** * @brief 通过viewController内的view,获取Controller * * @param view subView * * @return UIViewController */- (UIViewController *)recursionView2ViewController:(UIView *)view{ __block UIViewController *viewController;... 阅读全文
posted @ 2013-11-14 16:53 Maxfong 阅读(13304) 评论(0) 推荐(0) 编辑
摘要: iOS7之前的UI为:而在iOS7中,由于设计方面的原因,使得UI变为:修改的方法重写UINavigationItem的setLeftBarButtonItem和setRightBarButtonItem方法,使之与之前版本兼容;代码如下:@interface UINavigationItem (margin)@end@implementation UINavigationItem (margin)#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1- (void)setLeftBarButtonItem:(UIBarButtonItem 阅读全文
posted @ 2013-10-17 22:32 Maxfong 阅读(5406) 评论(8) 推荐(2) 编辑
摘要: 学OC,肯定知道内存管理机制的原则。这里说说某些特殊的情况。之前曾说,NSString的计数器比较特殊,大家注意下。今天说另外一种,也是比较纠结的,以至于朋友都说这是OC BUG。。。创建一个Class://H#import <Foundation/Foundation.h>@interface Car : NSObject- (void)show;@end//M#import "Car.h"@implementation Car- (void)show;{ NSLog(@"exec Finished!!!");}@end很简单的show方法 阅读全文
posted @ 2013-03-23 22:04 Maxfong 阅读(4430) 评论(6) 推荐(1) 编辑
摘要: /* 函数描述:字符串筛选,去掉不需要的特殊字符串 参数描述:target 原字符串 replacement 需要替换的字符串 options 默认传2:NSLiteralSearch,区分大小写 _replaceArray 需要排除的Array 返回值: 筛选完的String 备注: 使用方法:replaceOccurrencesOfString:@"1(2*3" withString:@"" options:2 replaceArray:[NSArray arrayWithObjects:@"(",@"*".. 阅读全文
posted @ 2013-01-28 22:53 Maxfong 阅读(2130) 评论(1) 推荐(1) 编辑
摘要: @property 官方解释:Declared Properties个人理解:@property的意思是自动帮添加get、set方法。而NSString等引用类型,需要使用retain。当我们不手动添加@property,如,建立一个私有变量,自己写get、set方法,通过消息发送,获取变量值。这里,如果此变量类型不为值类型,是否需要在set方法中,做@property的retain所做的事。个人觉得是需要的,即//H@property (nonatomic, retain) NSString *value;//M-(void)setValue:(NSString *)_value{ i... 阅读全文
posted @ 2012-12-08 14:06 Maxfong 阅读(2782) 评论(0) 推荐(1) 编辑
摘要: 1.需要添加一张启动图片,大小:640*1136,添加后默认命名为Default-568h@2x.png。图片适配,对于高清的1136图片,命名同样使用@2x,只是改名图片名称,如image-1-os5.png,image-1-os5@2x.png,在代码中判断iphone5?(image-1):(image-1-os5),没有@22x这种。#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScr 阅读全文
posted @ 2012-10-04 12:22 Maxfong 阅读(11260) 评论(0) 推荐(3) 编辑
摘要: 改写的AlertView,有弹出效果,点击任意位置关闭View。效果图:- (IBAction)didPressedClick:(id)sender{ alert = [[UIAlertView alloc] init]; alert.delegate = self; [alert addSubview:aView]; bView.layer.cornerRadius = 10; bView.layer.masksToBounds = YES; [bView.layer setShadowOffset:CGSizeMake(2, 1)]; [bView... 阅读全文
posted @ 2012-09-15 22:28 Maxfong 阅读(408) 评论(0) 推荐(0) 编辑
摘要: @interface Utility : NSObject{}//验证身份证是否有效+ (BOOL)checkIDCard:(NSString *)str;@end@interface Utility ()int checkIDfromchar (const char *sPaperId);@end@implementation Utility//验证身份证是否有效int checkIDfromchar (const char *sPaperId) { long lSumQT =0; int R[] ={7, 9, 10, 5, 8, 4, 2, 1, 6,... 阅读全文
posted @ 2012-09-04 16:00 Maxfong 阅读(396) 评论(0) 推荐(0) 编辑
摘要: 假设一段xml:///xmlStr/*<A> <B> <C id='c1'>C1</C> <C>C2</C> <C>C3</C> <C>C4</C> </B> <B> <C id='c2'>C5</C> <C>C6</C> <C>C7</C> </B></A>*/解析出C1-C7的数组: NSMutableArray *m_d 阅读全文
posted @ 2012-06-19 15:44 Maxfong 阅读(963) 评论(0) 推荐(0) 编辑