您的位置:首页 > 移动开发 > IOS开发

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐