文章分类 - iOS
摘要:猴子原创,欢迎转载。转载请注明: 转载自Cocos2D开发网--Cocos2Dev.com,谢谢!原文地址: http://www.cocos2dev.com/?p=261今天要在UIImageView中显示网络的图片,因为UIImageView自身就可以读取网络图片,所以,最简单的做法是:- (void)viewDidLoad{ [super viewDidLoad]; self.tv_headPic = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 80, 80)] autorelease];self.tv_headPic.lay
阅读全文
摘要:检查内存1。查一下autorelease的对象有没有在dealloc的时候release掉2。通常_titleLabel = [[UILabel alloc]init]; [self.viewaddSubview:_titleLabel]; 这个时候_titleLabel.retaincount = 2;在dealloc中_titleLabel.release之后_titleLabel.retaincount=1 不用管 最后一行的[super dealloc]会释放_titleLabel。注意:[super dealloc]必须放在 最后一行写。
阅读全文
摘要://第一种直接在textview的状态里判断 记得写textview的委托- (void)textViewDidBeginEditing:(UITextView *)textView{ bKeyBoardHide = NO;}- (void)textViewDidEndEditing:(UITextView *)textView{ bKeyBoardHide = YES;}第二种 键盘监控[[NSNotificationCenterdefaultCenter] addObserver:selfselector:@selector(keyboardWillShow:) name:UI...
阅读全文
摘要:常用代码整理:12.判断邮箱格式是否正确的代码://利用正则表达式验证-(BOOL)isValidateEmail:(NSString *)email{NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES%@",emailRegex];return [emailTest evaluateWithObject:emai
阅读全文
摘要:hackernewshttp://news.ycombinator.com/http://stackoverflow.com/
阅读全文
摘要:线程异步加载图片-(void)loadImageRes{ WaitingView* waittingView = [WaitingView waittingView]; //异步加载数据 dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);dispatch_async(queue, ^{ dispatch_async(dispatch_get_main_queue(), ^{ waittingView.center = CGPointMake(3...
阅读全文
摘要:iphone开发学习,iphone5页面适配修改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(CGSize
阅读全文
摘要:晚上提交app的时候总是报出icon的错误iPad: Icon.png: icon dimensions (0 x 0) don’t meet the size requirements. The icon file must be 72×72 pixels起初以为图片坏了, 后来才发现好像是 10.7.3 的系统bug修复方法:将Compress PNG Files 设置为 NO转自:http://www.lazyid.com/?p=373
阅读全文
摘要:.h中@protocol GeneralCellPadDelegate<NSObject>@required@optional- (void)showRemindView:(GeneralCellPad*)cell;-(BOOL) isCanInstallTheUpdate:(EntryUpdate*)entryUpdate;@end @property (nonatomic, assign) id<GeneralCellPadDelegate> delegate; .m中@synthesize delegate = _delegate; 利用tag取值1._setti
阅读全文
摘要:最有效的方法是:在willRotateToInterfaceOrientation:duration:方法中将方向存储起来:DrviceOrientation = toInterfaceOrientation;然后在别的方法中使用范例:先定义一个UIInterfaceOrientation deviceDirection;-(void)viewWillAppear:(BOOL)animated{ [selfsetFrameToRotation:deviceDirection];}-(void)willAnimateRotationToInterfaceOrientation:(UIInter.
阅读全文
摘要:ipad做横版竖版坐标可以写成横版:1024*0.5的格式 这样竖版直接可以用不需要再写一套坐标////竖版ipad坐标#define POR_WIDTH(X) (X*768)/1024#define POR_HEIGHT(Y)(Y*1024)/768注意:如果写成 (X/1024)*768 结果会变成0写成POR_HEIGHT((1280/2)+5)) 结果也是0 结论是不能先除
阅读全文
摘要:有两个视图,横屏视图和纵屏视图,当iphone的方位变化的时候,这两个视图相互切换。1。两个视图:PortraitView和LandscapeView ,分别标示纵屏和横屏。2。一个控制器,RootViewController,根控制器。3。在RootViewController.m中有以下代码-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ if (UIInterfaceOri...
阅读全文
摘要:这样判断会死人的啊。.xcode4.5不再支持armv6即:iOS4.3.3以下的系统.不被支持的硬件设备包括:iPod 2nd gen, iPhone 3G 或更老的iPhone例如我打包时的错误提示就是:warning: iOS deployment targets lower than 4.3 are not supported (current IPHONEOS_DEPLOYMENT_TARGET = "4.0", ARCHS = "armv7").(null):iPhone/iPod Touch: application executable
阅读全文
摘要://判断屏幕尺寸(固定的 不可以用这个判断高清) pad是height=1024 width=768 CGSize result = [[UIScreen mainScreen] bounds].size; //基本和上面的一样[[UIScreenmainScreen] applicationFrame].size.width//判断设备是否padif(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){}//打印设备信息 UIDevice *dev = [UIDevice currentDevice]; NSLog(@"dev
阅读全文
摘要:果设备屏幕相关网上流传的获取的当前设备dpi的方法:[html]view plaincopyfloatscale=1;if([[UIScreenmainScreen]respondsToSelector:@selector(scale)]){scale=[[UIScreenmainScreen]scale];}floatdpi=0;if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad){dpi=132*scale;}elseif(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone){dp
阅读全文
摘要:和iphone是一样的!!刚查了Apple的文档,图片的命名规则如下即可:Devices with out retina:ImageName.png - For iPhone/iPodImageName~ipad.png -- For iPadDevices with retina display:ImageName@2x~ipad.png -- For iPadImageName@2x.png- For iPhone/iPodApplications running in iOS 4 should now include two separate files for each image r
阅读全文
摘要:#pragma mark - 禁止点击-(void)setViewEnable:(BOOL)enable{ for (UIView* view inself.view.subviews) { if ([view isMemberOfClass:[UIButtonclass]] || [view isMemberOfClass:[UITextFieldclass]]) { view.userInteractionEnabled = enable; } } cancelBtn.userInteractionEnabled = YES;}
阅读全文
摘要:UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"最多只能输入500字" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil]; [alert show]; [alert release];- (void) alertView:(UIAlertView *)alertview clickedButtonAtIndex:(NSInteger)buttonIndex{ NS
阅读全文
摘要:UIActivityIndicatorView *_activityView = [[UIActivityIndicatorViewalloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; _activityView.center = CGPointMake(self.view.frame.size.width*0.8, self.view.frame.size.height*0.94 ); [self.view addSubview:_activityView];#pragm...
阅读全文
摘要:#pragma mark- MAC地址// Return the local MAC addy// Courtesy of FreeBSD hackers email list// Accidentally munged during previous update. Fixed thanks to mlamb.- (NSString *) macaddress{ int mib[6]; size_t len; char *buf; unsignedchar *ptr; struct if_msghdr *ifm; struct sockaddr_dl *sdl; mib[0]...
阅读全文

浙公网安备 33010602011771号