![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
iPhone开发
xyxdasnjss
这个作者很懒,什么都没留下…
展开
-
自定义UITableView的Header
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ // create the parent view that will hold header Label UIView* customView = [[UIView...原创 2012-08-28 19:13:05 · 109 阅读 · 0 评论 -
NSRange 的用法
NSRange的定义typedef struct _NSRange{ NSUInteger location; NSUInteger length;} NSRange; NSRange是一个结构体,其中location是一个以0为开始的index,length是表示对象的长度。他们都是NSUInteger类型。 而NSUInteger类型的定义如下:#if...原创 2012-09-11 13:58:55 · 70 阅读 · 0 评论 -
禁用UITabBarController双击事件
很多时候我们的程序操作结构都是UITabBarController+UINavigationController,每个UITabBarController item里面都有很多层的UINavigationController,而UITabBarController默认有一个事件就是双击UITabBarController item时,会把这个item里的UINavigationControlle...原创 2013-06-18 09:28:25 · 102 阅读 · 0 评论 -
UITableView小结
UITableViewDataSource #pragma mark - UITableViewDataSource//一共有多少组(可以不写,默认为1组)- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1;}//每个组有多少数据- (NSInte...原创 2013-06-18 10:03:40 · 88 阅读 · 0 评论 -
ios系统中各种设置项的url链接
ios系统中各种设置项的url链接 在代码中调用如下代码:NSURL*url=[NSURL URLWithString:@"prefs:root=WIFI"];[[UIApplication sharedApplication] openURL:url];即可跳转到设置页面的对应项。[font=]About — prefs:root=General&a...原创 2012-12-27 11:47:43 · 112 阅读 · 0 评论 -
ios事件的通知方法
1 手动广播者和监听者(Broadcaster and listeners)2键-值观察 key Value Observing3通知中心 notification center4 上下文通知 context notification5用于观察的weituo delegate 关于观察者观察者模式是维持两个模块之间抽象关系的最强大的方式之一。观察者模式包括一个发布已发...原创 2013-01-04 15:23:21 · 86 阅读 · 0 评论 -
利用dispatch_once创建单例
http://bj007.blog.51cto.com/1701577/649413无论是爱还是恨,你都需要单例。实际上每个iOS或Mac OS应用都至少会有UIApplication或NSApplication.什么是单例呢?Wikipedia是如此定义的:在软件工程中,单例是一种用于实现单例的数学概念,即将类的实例化限制成仅一个对象的设计模式。或者我的理解是:...原创 2013-01-04 15:29:02 · 53 阅读 · 0 评论 -
保持iOS设备屏幕常亮的方法
因为自己的应用程序运行的时候需要保持屏幕常亮,可以加入以下语句:(一)如果是在Xcode中做开发:[ [ UIApplication sharedApplication] setIdleTimerDisabled:YES ] ;设置为YES保持屏幕常亮.(二)如果在Unity3D中:iPhoneSettings.screenCanDarken =false...原创 2013-01-04 15:41:40 · 86 阅读 · 0 评论 -
UIView的clipsToBounds属性
clipsToBounds属性取值:BOOL(YES/NO)作用:决定了子视图的显示范围。具体的说,就是当取值为YES时,剪裁超出父视图范围的子视图部分;当取值为NO时,不剪裁子视图。默认值为NO。如下图所示:view2是view1的子视图取值为NO时: 取值为YES时: ...原创 2013-01-05 10:53:14 · 64 阅读 · 0 评论 -
iOS 本地化应用程序汇总 国际化
http://chenjohney.iteye.com/blog/1303723 最近要做一个应用要实现本地化,因为使用的是xcode4,应用程序本地化的问题跟以前的版本还是有些不同,在网上找了些资料对于xcode4以上的版本资料还是相对较少,有些最后要通过手动创建文件,这样操作实在是太麻烦,所以经过一个下午的研究,总算是成功了一点点,还是庆幸一下。先给出结果。英语: ...原创 2012-12-19 15:17:32 · 131 阅读 · 0 评论 -
设备判断 iphone3? iphone4? iphone5?
//.h#import <Foundation/Foundation.h>#import <sys/utsname.h>@interface DeviceInfo : NSObject+(NSString*)deviceString;+(BOOL)isRetina;@end//.m#import "Devic...原创 2012-12-18 13:46:10 · 69 阅读 · 0 评论 -
关于缺少各种framework出现的错误累结
经常会调用到各种外部文件,在引用一些外部的文件的时候可能会出现一些错误提示,是在link阶段出现一些error,错误界面如下:通常解决方法为在项目中添加相应的类库:选中项目 -> Build Phases -> Link Binary With Libraries -> 点击+ -> 搜索合适的库 -> 点击Add -> 重新编译如果是自己...原创 2012-12-14 16:26:15 · 309 阅读 · 0 评论 -
UIImageView 旋转
CABasicAnimation* rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];rotationAnimation.toValue = [NSNumber numberWithFloat:(DEGREES_TO_RADIANS(360))];rotationAn...原创 2012-08-28 19:19:46 · 77 阅读 · 0 评论 -
CCMenuItemToggle的使用
这个可以作为CCmenu的一个item,和CCMenuItemSprite一起使用不同的是,CCMenuItemToggle在点击之后,可以变化图片CCSprite* pauseNormalSprite1 = [CCSprite spriteWithSpriteFrame:[cacheCommon spriteFrameByName:@"pause.png"]];CCSprite...原创 2012-12-07 17:21:45 · 80 阅读 · 0 评论 -
CCCallFunc, CCCallFuncN, CCCallFuncND 三者的区别
1.CCCallFunc 只能调用不带参数的回调方法2.CCCallFuncN 可以带一个 参数:(id)sender3.CCCallFuncND 可以带两个参数 (第二个参数的类型可以是任意类型):(id)sender batchNode:(CCSpriteBatchNode*)batchNode 直接上用例(sprite动画一次性播放以后将自己从父节点移除并销毁):...原创 2012-12-10 18:31:26 · 78 阅读 · 0 评论 -
【2.0版本cocos2d-iphone 开发之CCProgressTimer制作游戏中的血条】
作者:zhangxinlin转载请注明,原文链接:http://blog.csdn.net/zhang429350061/article/details/8275225 第一次写博客,最近在学习和同僚们的交流过程中整理了一些cocos2d的知识,放在博客里和大家学习交流。希望大牛们多给指导意见,共同进步。1.首先说一下cocos2d中1.0版本和2.0版本中关于CCProgr...原创 2012-12-11 12:43:34 · 94 阅读 · 0 评论 -
UIButton左对齐
[_favoriteBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];//左对齐原创 2013-05-20 17:17:17 · 66 阅读 · 0 评论 -
重写、修改UINavigationController的back键的title
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] init]; barButtonItem.title = @"buttonName"; self.navigationItem.backBarButtonItem = barButtonItem; [barButtonItem release]; ...原创 2012-08-29 11:21:58 · 104 阅读 · 0 评论 -
Xcode 真机测试时出现shell Script invocation Error解决方案
我遇到的问题shell Script invocation Error ,Command /bin/sh failed with exit code 2解决方案:查看build phase里面run script是否写的正确,必要时可以删除试一下原创 2012-08-29 16:05:03 · 118 阅读 · 0 评论 -
动画CATransition 从下往上、从上往下
//动画效果 // 从上往下 CATransition *animation = [CATransitionanimation]; //animation.delegate = self; animation.duration = 0.4f; animation.timingFunction = UIViewAnimationCurveEaseInOu...原创 2012-08-29 17:13:35 · 470 阅读 · 0 评论 -
Tried to obtain the web lock from a thread解决方法之一
http://blog.csdn.net/musou_ldns/article/details/7242359项目中一个UIViewController内使用异步线程,异步线程未执行完时pop退出此画面,程序crash。控制台打出错误如下: Tried to obtain the web lock from a thread other than the main thread......原创 2013-01-07 10:59:16 · 101 阅读 · 0 评论 -
判断是否是 emoji表情
+ (BOOL)stringContainsEmoji:(NSString *)string{ __block BOOL returnValue = NO; [string enumerateSubstringsInRange:NSMakeRange(0, [string length]) options:NSStringEnumerationByComposedChar...原创 2013-06-28 09:42:15 · 94 阅读 · 0 评论 -
自定义UITableViewCell上的delete按钮
//通过UITableViewDelegate方法可以实现删除 tableview中某一行 //滑动删除-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPa...原创 2013-06-28 10:35:13 · 87 阅读 · 0 评论 -
UIColor (XYCategory)
#import <UIKit/UIKit.h>@interface UIColor (XYCategory)+ (UIColor *)colorWithHex:(long)hexColor;+ (UIColor *)colorWithHex:(long)hexColor alpha:(float)opacity;+ (UIColor *)colorWithHe...原创 2014-06-19 22:13:22 · 81 阅读 · 0 评论 -
UIView (Additon)
#import <UIKit/UIKit.h>@interface UIView (Additon)/** * Shortcut for frame.origin.x. * * Sets frame.origin.x = left */@property (nonatomic) CGFloat left;/** * Shortcut f...原创 2014-06-19 22:23:13 · 108 阅读 · 0 评论 -
iOS7滑动返回
http://blog.csdn.net/wmqi10/article/details/16850479 iOS 7中在传统的左上角返回键之外,提供了右滑返回上一级界面的手势。支持此手势的是UINavigationController中新增的属性interactivePopGestureRecognizer,即右滑返回只支持以UINavigationController为容器的Vie...原创 2014-06-24 11:48:47 · 81 阅读 · 0 评论 -
iOS使用NSClassFromString
http://www.cocoachina.com/b/?p=219 NSClassFromString是一个很有用的东西,尤其在进行iPhone toolchain的开发上。正常来说,id myObj = [[NSClassFromString(@"MySpecialClass") alloc] init];和id myObj = [[MySpecialClass al...原创 2014-03-07 11:24:54 · 111 阅读 · 0 评论 -
UITableView 隐藏多余的Cell的分割线
- (void)setExtraCellLineHidden: (UITableView *)tableView{ UIView *view = [UIView new]; view.backgroundColor = [UIColor clearColor]; [tableView setTableFooterView:view];}原创 2015-02-02 14:39:22 · 113 阅读 · 0 评论 -
iOS7 开发相关
1.UITableView reloadData 之后,显示的cell移动?有时还会消失?因为使用了- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath 这个方法,去掉后 就好了。 2.iOS状态栏和导航栏不占位 ...原创 2013-10-22 10:17:29 · 75 阅读 · 0 评论 -
iOS之ARC下的Block
http://www.cnblogs.com/tekkaman/archive/2012/05/02/2478601.html iOS之ARC下的Block【ARC的特性】 ARC下,所有NSObject类型指针, 1. 默认为__strong类型 2. 可以显示的指定为__weak类型,__weak类型指针在所指向对象销毁后会自动置为nil 3. _...原创 2015-04-15 14:37:03 · 93 阅读 · 0 评论 -
UILabel顶端对齐
http://shfzhzhr.iteye.com/blog/1808000 code中默认的UILabel是垂直居中对齐的,如果你的UILabel高度有多行,当内容少的时候,会自动垂直居中。 比较郁闷的是,UILabel并不提供设置其垂直对齐方式的选项。所以如果你想让你的文字顶部对齐,那么就需要自己想办法了。 stackoverflow.com 上提供了几...原创 2014-09-10 10:15:37 · 81 阅读 · 0 评论 -
OC MD5
#import <Foundation/Foundation.h>@interface MD5Util : NSObject+ (NSString *)md5HexDigest:(NSString*)input;@end #import "MD5Util.h"#import <CommonCrypto/CommonDigest....原创 2014-06-19 21:50:07 · 104 阅读 · 0 评论 -
iPad横版开发时,宽高是反的
最近刚开始做iPad版应用,但发现横版的时候宽高是反的,很别扭,所以在网上找了一段代码,能够很好的输出宽高 #define SCREEN_WIDTH ((([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) || ([UIApplication sharedAp...原创 2013-08-14 18:01:41 · 191 阅读 · 0 评论 -
IOS判断设备是否已越狱(isJailbroken)
@interface UIDevice (Helper) - (BOOL)isJailbroken; @end@implementation UIDevice (Helper) - (BOOL)isJailbroken { BOOL jailbroken = NO; NSString *cydiaPath = @"/Applications/Cydi...原创 2014-06-03 21:17:55 · 197 阅读 · 0 评论 -
教你如何在lion下mac共享网络给iphone4无线上网
http://bbs.appvv.com/thread-46903-1-1.html 本人用的是路由器 网线接电脑 可能公司原因 是不用pppoe拨号的 意思就是插上电脑 电脑什么都不用点就已经可以打开网页上网---------------------------------------------------下面副设置 不知道其他网络连接方式可以共享不 我只是分享下我的宽带连接方式下共享...原创 2013-01-09 11:05:24 · 131 阅读 · 0 评论 -
判断NSString是否为数字,以及转换为数字
http://hi.baidu.com/aidfan/item/377dd6dd751b0cf793a9743d 当NSString为纯数字的时候可以用下面的方法://判断是否为整形:- (BOOL)isPureInt:(NSString*)string{ NSScanner* scan = [NSScanner scannerWithString:string]; int...原创 2013-01-16 13:42:47 · 88 阅读 · 0 评论 -
new 与 alloc/init的区别
http://blog.csdn.net/abby_sheen/article/details/7818797 英文详解:http://macresearch.org/difference-between-alloc-init-and-new我也是转来的:http://blog.csdn.net/ch_soft/article/details/73877311.在实际开发中很少会...原创 2013-07-11 14:47:34 · 81 阅读 · 0 评论 -
Xcode 4.4中LLVM compiler 4.0带来的Objective-C新语法特性
http://blog.csdn.net/totogo2010/article/details/7990792今年WWDC 2012苹果全球开发者大会上,苹果针对LLVM编译器都做了重大改进,新版的Xcode 4.4中的LLVM编译器升级到了4.0,给Objective-C带来了很多令人惊喜的特性。注意,下面的语法需要下载Xcode 4.4。1、枚举类型的改变老写法: ...原创 2013-07-15 10:56:25 · 85 阅读 · 0 评论 -
UITableView 只更新某行
如果全部更新的话用reloadData方法 如果只是更新某几行数据的时候, NSIndexPath *indexPath_1 = [NSIndexPath indexPathForRow:0 inSection:1]; NSArray *indexArray = [NSArray arrayWithObject:indexPath_1]; [self.m...原创 2013-07-22 10:10:57 · 119 阅读 · 0 评论 -
IOS开发之----四舍五入问题
方法一: -(NSString *)notRounding:(float)price afterPoint:(int)position{ NSDecimalNumberHandler* roundingBehavior = [NSDecimalNumberHandler decimalNumberHandlerWithRoundingMode:NSRoundDown scal...原创 2013-02-18 12:32:50 · 129 阅读 · 0 评论