代码改变世界

AVAudioPlayer 在dealloc中release时exc_bad_access问题

2012-12-26 14:30 by Y_York, 255 阅读, 0 推荐, 收藏, 编辑
摘要:搞了将近一个小时,在ios6以下的模拟器中都没有问题,只有在ios6中dealloc ViewController时会出现这个问题。原来的代码是这样的:- (void)dealloc { [super dealloc]; [_player release];}最后发现只要改成这样就行,换一下顺序而已,法克!第一次发现super dealloc的顺序不能随便摆,以后统一放最后一句吧- (void)dealloc { [_player release]; [super dealloc];} 阅读全文

NSUserDefaults保存问题

2012-12-05 15:24 by Y_York, 269 阅读, 0 推荐, 收藏, 编辑
摘要:If you terminate your app by pressing the home button (in the Simulator or on the device), your User Defaults will get saved.If you terminate your app by pressing "Stop" in Xcode (in the Simulator or on the device), your User Defaultsmightget saved, but there's a good chance they won&# 阅读全文

iOS自带的背景图片

2012-11-04 20:15 by Y_York, 330 阅读, 0 推荐, 收藏, 编辑
摘要:原来这张经典的图和分组表的背景一样,都是背景自带的呀。self.view.backgroundColor = [UIColor groupTableViewBackgroundColor]; +(UIColor *)scrollViewTexturedBackgroundColorDescriptionReturns the system pattern color used to render the area behind scrollable content.ReturnsThe UIColor object.AvailabilityiOS (3.2 and later)Declared 阅读全文

自定义UIActionSheet背景、按钮

2012-10-14 19:43 by Y_York, 3269 阅读, 0 推荐, 收藏, 编辑
摘要:1. 自定义ActionSheet背景首先 #import <QuartzCore/QuartzCore.h>然后实现UIActionSheetDelegate方法:- (void)willPresentActionSheet:(UIActionSheet*)actionSheet { UIImage*theImage =[UIImage imageNamed:@"detail_menu_bg.png"]; theImage =[theImage stretchableImageWithLeftCapWidth:32 topCapHeight:32]; CGSi 阅读全文

Cocoa Touch 移动控件动画

2012-08-23 15:11 by Y_York, 211 阅读, 0 推荐, 收藏, 编辑
摘要:ios 4.0之后的方法// set the original framebutton.frame =CGRectMake(30,50,100,100);// animate[UIView animateWithDuration:0.75 animations:^{ button.frame =CGRectMake(10,70,100,100);}];旧版方法为:button.frame =CGRectMake(30,50,100,100);// animate to the new one[UIView beginAnimations:nil context:NULL];[UIView s. 阅读全文

NSString中添加百分号

2012-08-23 09:16 by Y_York, 3294 阅读, 0 推荐, 收藏, 编辑
摘要:百分号在objc中是%%,例如:NSString *criteria = [NSString stringWithFormat:@"WHERE username LIKE '%@%%'",name]; 阅读全文

UISearchDisplayController在dealloc时调用_destroyManagedTableView时出异常

2012-08-20 15:57 by Y_York, 180 阅读, 0 推荐, 收藏, 编辑
摘要:最简单的解决办法是在拥有UISearchDisplayController的控制器的dealloc方法中加上三行代码:self.searchDisplayController.delegate = nil;self.searchDisplayController.searchResultsDelegate = nil;self.searchDisplayController.searchResultsDataSource = nil;这样问题就圆满解决了 ;-) 阅读全文