IOS实际开发中学习到的知识
2013-06-20 15:58
429 查看
//对于类方法,此方法可用,但是没有提示
[[self class] respondsToSelector:@selector(sharedSubTabBarController)];
//获取系统info.plist文件中的键值对
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
//获取软件的版本号
NSString *version = [infoDict objectForKey:@"CFBundleVersion"];
NSLog(@"版本号是= %@",version);
CGContextFlush(context); //刷新
#define BARBUTTON(TITLE, SELECTOR) [[[UIBarButtonItem alloc] initWithTitle:TITLE style:UIBarButtonItemStyleBordered target:self action:SELECTOR] autorelease]
#define Release(i) [i release];i=nil
[NSObject cancelPreviousPerformRequestsWithTarget:self];
CGRect cubeFrame = {{0, 0}, {320, 60}};
-(void)turn{
CATransition *animation = [CATransition animation];
animation.delegate = self;
animation.duration = 0.5f;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = kCAFillModeForwards;
animation.endProgress = 1;
animation.removedOnCompletion = NO;
animation.type = @"cube";
[self.view.layer addAnimation:animation forKey:@"animation"];
self.lastAnimation = animation;
}
/Users/XXX/Library/Developer/Xcode/DerivedData
此路径删除后,可解决方法不能点击
4.0以上动画效果实现
[UIView animateWithDuration:0.5f
animations:^{
faceBigview.alpha = 1.0f;
[faceBigview setFrame:[[UIScreen mainScreen]bounds]];
}
completion:^(BOOL finished){
}];
UIWebView怎么禁用掉长按后的文字选择框
document.body.style.webkitTouchCallout='none'
ThirdViewController * third =[[ThirdViewController alloc] init];
third.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:third animated:YES];
[third release];
XCode4设置不太一样: 在Edit-->Scheme里面 找到Arguments
把下面3个值设置成YES
NSAutoreleaseFreedObjectCheckEnabled
NSZombieEnabled
NSDebugEnabled
NSString *text = @"i'm a 苹果。...";
int length = [text length];
for (int i=0; i<length; ++i)
{
NSRange range = NSMakeRange(i, 1);
NSString *subString = [text substringWithRange:range];
c*****t char *cString = [subString UTF8String];
if (strlen(cString) == 3)
{
NSLog(@"汉字:%s", cString);
}
}
//NSLog中打印引号
@"This will always display because the condition is \"true\""
//打印当前方法名称
NSLog(@"%@",NSStringFromSelector(_cmd));
CFUUIDRef deviceId = CFUUIDCreate (NULL);
CFStringRef deviceIdStringRef = CFUUIDCreateString(NULL,deviceId);
CFRelease(deviceId);
NSString *deviceIdString = (NSString *)deviceIdStringRef;
NSUserDefaults *standardUserDefault = [NSUserDefaults standardUserDefaults];
[standardUserDefault setValue:deviceIdString forKey:@"deviceId"];
[deviceIdString release];
[standardUserDefault synchronize];
程序进入断点后就崩溃解决方法
products->debugWorkflow->最后一个勾去掉
注意不要用#ifdef TARGET_IPHONE_SIMULATOR, 因为在device上, TARGET_IPHONE_SIMULATOR被定义为0。、
应该使用 #if TARGET_IPHONE_SIMULATOR
lbMobile.textColor = [UIColor colorWithARGB:0xFFE75208];
+(UIColor *)colorWithARGB:(int)argb
{
CGFloat fAlpha = ((argb >> 24) & 0xFF)/255.0f;
CGFloat fRed = ((argb >> 16) & 0xFF)/255.0f;
CGFloat fGreen = ((argb >> 8) & 0xFF)/255.0f;
CGFloat fBlue = (argb & 0xFF)/255.0f;
return [UIColor colorWithRed:fRed green:fGreen blue:fBlue alpha:fAlpha];
}
从服务器返回的空字符串,生成的对象,对象存在,长度为0
空对象nil的length 也是0 与@"" 刚好保持一致
//用户评论,不能在模拟器测试
@"http://itunes.apple.com/cn/app/id457959333?mt=8";
NSString * urlStr=@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=433602054";
NSLog(@"urlStr %@",urlStr);
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:urlStr]];
//分别为 0 1 2 3
enum {PDF, IMAGE, PROCEDURAL, NUM_EXAMPLES};
//简单枚举定义
typedef enum _MSHelpStrType
{
MSHelpStrTypeMain = 1,
MSHelpStrTypeSHFF = 2,
MSHelpStrTypeGNJS = 3
} MSHelpStrType;
//系统定义的模拟器宏定义
#ifdef TARGET_IPHONE_SIMULATOR
TARGET_IPHONE_SIMULATOR
显示:defaults write com.apple.finder AppleShowAllFiles -bool true
隐藏:defaults write com.apple.finder AppleShowAllFiles -bool false
//通过img视图,创建出新的imgview
UIGraphicsBeginImageContext(drawImageViewTemp.frame.size);
[drawImageViewTemp.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIKit中包含了UIGestureRecognizer类,用于检测发生在设备中的手势。UIGestureRecognizer是一个抽象类,定义了所有手势的基本行为,它有下面一些子类用于处理具体的手势:
1、拍击UITapGestureRecognizer (任意次数的拍击)
2、向里或向外捏UIPinchGestureRecognizer (用于缩放)
3、摇动或者拖拽UIPanGestureRecognizer
4、擦碰UISwipeGestureRecognizer (以任意方向)
5、旋转UIRotationGestureRecognizer (手指朝相反方向移动)
6、长按UILongPressGestureRecognizer
[[self class] respondsToSelector:@selector(sharedSubTabBarController)];
//获取系统info.plist文件中的键值对
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
//获取软件的版本号
NSString *version = [infoDict objectForKey:@"CFBundleVersion"];
NSLog(@"版本号是= %@",version);
CGContextFlush(context); //刷新
#define BARBUTTON(TITLE, SELECTOR) [[[UIBarButtonItem alloc] initWithTitle:TITLE style:UIBarButtonItemStyleBordered target:self action:SELECTOR] autorelease]
#define Release(i) [i release];i=nil
[NSObject cancelPreviousPerformRequestsWithTarget:self];
CGRect cubeFrame = {{0, 0}, {320, 60}};
-(void)turn{
CATransition *animation = [CATransition animation];
animation.delegate = self;
animation.duration = 0.5f;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = kCAFillModeForwards;
animation.endProgress = 1;
animation.removedOnCompletion = NO;
animation.type = @"cube";
[self.view.layer addAnimation:animation forKey:@"animation"];
self.lastAnimation = animation;
}
/Users/XXX/Library/Developer/Xcode/DerivedData
此路径删除后,可解决方法不能点击
4.0以上动画效果实现
[UIView animateWithDuration:0.5f
animations:^{
faceBigview.alpha = 1.0f;
[faceBigview setFrame:[[UIScreen mainScreen]bounds]];
}
completion:^(BOOL finished){
}];
UIWebView怎么禁用掉长按后的文字选择框
document.body.style.webkitTouchCallout='none'
ThirdViewController * third =[[ThirdViewController alloc] init];
third.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:third animated:YES];
[third release];
XCode4设置不太一样: 在Edit-->Scheme里面 找到Arguments
把下面3个值设置成YES
NSAutoreleaseFreedObjectCheckEnabled
NSZombieEnabled
NSDebugEnabled
NSString *text = @"i'm a 苹果。...";
int length = [text length];
for (int i=0; i<length; ++i)
{
NSRange range = NSMakeRange(i, 1);
NSString *subString = [text substringWithRange:range];
c*****t char *cString = [subString UTF8String];
if (strlen(cString) == 3)
{
NSLog(@"汉字:%s", cString);
}
}
//NSLog中打印引号
@"This will always display because the condition is \"true\""
//打印当前方法名称
NSLog(@"%@",NSStringFromSelector(_cmd));
CFUUIDRef deviceId = CFUUIDCreate (NULL);
CFStringRef deviceIdStringRef = CFUUIDCreateString(NULL,deviceId);
CFRelease(deviceId);
NSString *deviceIdString = (NSString *)deviceIdStringRef;
NSUserDefaults *standardUserDefault = [NSUserDefaults standardUserDefaults];
[standardUserDefault setValue:deviceIdString forKey:@"deviceId"];
[deviceIdString release];
[standardUserDefault synchronize];
程序进入断点后就崩溃解决方法
products->debugWorkflow->最后一个勾去掉
注意不要用#ifdef TARGET_IPHONE_SIMULATOR, 因为在device上, TARGET_IPHONE_SIMULATOR被定义为0。、
应该使用 #if TARGET_IPHONE_SIMULATOR
lbMobile.textColor = [UIColor colorWithARGB:0xFFE75208];
+(UIColor *)colorWithARGB:(int)argb
{
CGFloat fAlpha = ((argb >> 24) & 0xFF)/255.0f;
CGFloat fRed = ((argb >> 16) & 0xFF)/255.0f;
CGFloat fGreen = ((argb >> 8) & 0xFF)/255.0f;
CGFloat fBlue = (argb & 0xFF)/255.0f;
return [UIColor colorWithRed:fRed green:fGreen blue:fBlue alpha:fAlpha];
}
从服务器返回的空字符串,生成的对象,对象存在,长度为0
空对象nil的length 也是0 与@"" 刚好保持一致
//用户评论,不能在模拟器测试
@"http://itunes.apple.com/cn/app/id457959333?mt=8";
NSString * urlStr=@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=433602054";
NSLog(@"urlStr %@",urlStr);
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:urlStr]];
//分别为 0 1 2 3
enum {PDF, IMAGE, PROCEDURAL, NUM_EXAMPLES};
//简单枚举定义
typedef enum _MSHelpStrType
{
MSHelpStrTypeMain = 1,
MSHelpStrTypeSHFF = 2,
MSHelpStrTypeGNJS = 3
} MSHelpStrType;
//系统定义的模拟器宏定义
#ifdef TARGET_IPHONE_SIMULATOR
TARGET_IPHONE_SIMULATOR
显示:defaults write com.apple.finder AppleShowAllFiles -bool true
隐藏:defaults write com.apple.finder AppleShowAllFiles -bool false
//通过img视图,创建出新的imgview
UIGraphicsBeginImageContext(drawImageViewTemp.frame.size);
[drawImageViewTemp.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIKit中包含了UIGestureRecognizer类,用于检测发生在设备中的手势。UIGestureRecognizer是一个抽象类,定义了所有手势的基本行为,它有下面一些子类用于处理具体的手势:
1、拍击UITapGestureRecognizer (任意次数的拍击)
2、向里或向外捏UIPinchGestureRecognizer (用于缩放)
3、摇动或者拖拽UIPanGestureRecognizer
4、擦碰UISwipeGestureRecognizer (以任意方向)
5、旋转UIRotationGestureRecognizer (手指朝相反方向移动)
6、长按UILongPressGestureRecognizer
相关文章推荐
- IOS科研IOS开发笔记学习基础知识
- ios开发学习 --基础知识--系列教程
- IOS开发-Swift-基础知识学习笔记
- 如何学习才能快速成为ios开发高手--ios知识架构全方位探讨
- 【iOS开发-33】学习手动内存管理临时抛弃ARC以及retain/assign知识——iOSproject师面试必考内容
- iOS开发学习专题-基础知识(一)NSString NSMutableString NSRange NSNotFound详细使用方式
- 如何学习才能快速成为ios开发高手--ios知识架构全方位探讨
- ios开发runtime学习三:动态添加方法(实际应用少,面试)
- IOS开发学习笔记009-OC基本知识
- IOS 开发学习一 基础知识
- iOS开发学习手动内存管理暂时抛弃ARC以及retain/assign知识——iOS工程师面试必考内容
- IOS 核心开发课程---学习步骤---应该掌握的知识
- 【iOS知识学习】_iPhone开发必经
- IOS 核心开发课程---学习步骤---应该掌握的知识
- iOS开发学习专题-基础知识(四) NSNumber容器 NSData数据 NSData转换的详细使用方式
- iOS开发学习专题-基础知识(五) NSDate时间 NSUserDefaults本地存储 NSNotification系统通知的详细使用方式
- iOS开发学习专题-基础知识(三)NSDictionary字典NSMutableDictionary可变字典NSDictionary字典和json转换详细使用方式
- iOS开发学习笔记(一) - 预备知识(1)
- 【Objective-C】01-学习iOS开发前期知识积累之C语言知识大总结
- IOS开发学习中的基础知识究竟有多重要?