随笔分类 -  代码案例

摘要:-(UIImage*) convertToGreyscale:(UIImage*)i {int kRed =1;int kGreen =2;int kBlue =4;int colors = kGreen;int m_width = i.size.width;int m_height = i.size.height;uint32_t*rgbImage =(uint32_t*) malloc(m_width * m_height *sizeof(uint32_t));CGColorSpaceRef colorSpace =CGColorSpaceCreateDeviceRGB();CGConte 阅读全文
posted @ 2013-09-03 11:51 高笑228 阅读(389) 评论(0) 推荐(0)
摘要:焦点在UITextField或UITextView中的时候,键盘会出现,想点一下背景就让键盘消失。这是在手持设备上服合用户的操作习惯。当然方法有很多,在这儿我说一个比较实用的方法。因为UIView默认是不能关联方法调用的,而UIControl则不一样,它可以关联很多方法。而UIControl是UIView的子类,它有UIView的所有特性,于是我们可以把我们的UIView修改为UIControl类,这样再给它关联一个事件,一般就是up in side,这样在这个关联的事件里我们dismiss所有的UITextField或UITextView.这儿有一个递归找view上所有的UiTextFiel 阅读全文
posted @ 2013-05-09 17:55 高笑228 阅读(243) 评论(0) 推荐(0)
摘要:在iOS 5下画面的旋转都是shouldAutorotateToInterfaceOrientation来控制的,但是这个函数在ios6下不起作用。在iOS 6下使用supportedInterfaceOrientations、shouldAutorotate来控制。如果单一的控制画面那么只需要加在上面两个函数。如下:123456789- (BOOL)shouldAutorotate { return YES;}- (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll;}如果是含有.. 阅读全文
posted @ 2013-04-17 11:35 高笑228 阅读(220) 评论(0) 推荐(0)
摘要:- (void) setUpAndAddAudioAtPath:(NSURL*)assetURL toComposition:(AVMutableComposition *)composition start:(CMTime)start dura:(CMTime)dura offset:(CMTime)offset{ AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL:assetURL options:nil]; AVMutableCompositionTrack *track = [composition addMutableTrack.. 阅读全文
posted @ 2013-03-04 15:39 高笑228 阅读(4139) 评论(0) 推荐(0)
摘要:转自 http://alldunne.org/2011/09/how-to-pause-or-end-a-uiview-animation-via-the-calayer/-(void)pauseLayer:(CALayer*)layer{ CFTimeInterval paused_time = [layer convertTime:CACurrentMediaTime() fromLayer:nil]; layer.speed = 0.0; layer.timeOffset = paused_time; }-(void)resumeLayer:(CALayer*)layer{ ... 阅读全文
posted @ 2013-01-28 17:27 高笑228 阅读(226) 评论(0) 推荐(0)
摘要:本文转载自http://www.cocoachina.com/bbs/read.php?tid=31300一:确认网络环境3G/WIFI mm IOgl jUj3 'e.p 1. 添加源文件和framework "K*iGP Yf ?mEZm 开发Web等网络应用程序的时候,需要确认网络环境,连接情况等信息。如果没有处理它们,是不会通过Apple的审查的。 hS(<R!1,i Apple 的 例程 Reachability 中介绍了取得/检测网络状态的方法。要在应用程序程序中使用Reachability,首先要完成如下两部: 8IvI|$[t 阅读全文
posted @ 2012-11-29 11:38 高笑228 阅读(293) 评论(0) 推荐(0)
摘要:http://stackoverflow.com/questions/11199421/xcode-lldb-watchpoints 阅读全文
posted @ 2012-11-17 16:47 高笑228 阅读(158) 评论(0) 推荐(0)
摘要:http://bj007.blog.51cto.com/1701577/634438 阅读全文
posted @ 2012-11-16 10:02 高笑228 阅读(133) 评论(0) 推荐(0)
摘要:http://285746555.blog.51cto.com/2966432/658383 阅读全文
posted @ 2012-08-04 16:18 高笑228 阅读(137) 评论(0) 推荐(0)
摘要:NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; NSDate *date =[[[NSDate alloc]initWithTimeIntervalSince1970:[cobj.time doubleValue]]autorelease]; // NSLog(@"%@", date); NSString *strDate = [dateFormatter strin 阅读全文
posted @ 2012-07-29 21:32 高笑228 阅读(131) 评论(0) 推荐(0)
摘要:http://www.cocoachina.com/bbs/read.php?tid=108119 阅读全文
posted @ 2012-07-18 00:22 高笑228 阅读(123) 评论(0) 推荐(0)
摘要:- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { ... 阅读全文
posted @ 2012-07-12 10:18 高笑228 阅读(2111) 评论(0) 推荐(0)
摘要:iPhone上实现Default.png动画iPhone上实现Default.png动画 原理: 添加一张和Default.png一样的图片,对这个图片进行动画,从而实现Default动画的渐变消失的效果。 操作: 在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOpti*****:(NSDictionary *)launchOpti*****中添加如下代码: // Make this interesting. UIImageView *s... 阅读全文
posted @ 2012-07-09 11:03 高笑228 阅读(273) 评论(0) 推荐(0)
摘要:在头文件中引入framework加入#import <MessageUI/MessageUI.h> 到InAppEmailViewController.h显示 MFMailComposeViewController UIMFMailComposeViewController与其他view controller一样; 我们可以在InAppEmailViewController 使用presentModalViewController使其滑入屏幕。替换InAppEmailController.m中的buttonPressed方法:1234567- (IBAction)buttonPre 阅读全文
posted @ 2012-06-18 12:09 高笑228 阅读(207) 评论(0) 推荐(0)
摘要:一、给图片加上阴影 UIImageView*pageContenterImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"onePageApple.png"]]; //添加边框 CALayer*layer = [pageContenterImageView layer]; layer.borderColor= [[UIColor whiteColor]CGColor]; layer.bo... 阅读全文
posted @ 2012-05-12 23:19 高笑228 阅读(282) 评论(0) 推荐(0)
摘要:UIAlertView * baseAlert; baseAlert =[[[UIAlertView alloc]initWithTitle:@"please wait" message:nildelegate:self cancelButtonTitle:nil otherButtonTitles:nil]autorelease];//定义[baseAlert show];UIActivityIndicatorView *aiv = [[UIActivityIndicatorViewalloc]initWithActivityIndicatorStyle:UIActivi 阅读全文
posted @ 2012-05-04 23:28 高笑228 阅读(171) 评论(0) 推荐(0)
摘要:- (void)viewDidLoad{[super viewDidLoad];UIImage * image = [UIImage imageNamed:@"alien.png"];CGSize size = image.size;UIImageView *imgview = [[UIImageView alloc]initWithFrame:(CGRect){{100,100},size}];imgview.image = image; [self.view addSubview:imgview];imgview.userInteractionEnabled = YES 阅读全文
posted @ 2012-05-04 23:22 高笑228 阅读(234) 评论(0) 推荐(0)
摘要:代码: //选择按钮NSArray*buttonNames = [NSArray arrayWithObjects:@"今天", @"本周", @"本月",nil]; UISegmentedControl * segmentedControl = [[UISegmentedControl alloc]initWithItems:buttonNames];[segmentedControl setFrame:CGRectMake(60, 10, 200, 40)]; segmentedControl.selectedSegmentInd 阅读全文
posted @ 2012-05-04 23:21 高笑228 阅读(166) 评论(0) 推荐(0)
摘要:获取当前的系统时间 年-月-日 小时-分钟-秒代码如下:NSDate * newDate = [NSDate date];//实例化一个NSDateFormatter对象NSDateFormatter*dateformat=[[NSDateFormatter alloc]init];//设定时间格式,这里可以设置成自己需要的格式[dateformatsetDateFormat:@"yyyy-MM-dd HH:mm:ss"];NSString *newDateOne = [dateformatstringFromDate:newDate];[dateformatsetForm 阅读全文
posted @ 2012-05-04 23:17 高笑228 阅读(1464) 评论(0) 推荐(0)
摘要:线程(thread):用于指代独立运行的代码段进程(process):用于指代正在运行的可执行程序,它可以包含多个线程RunLoop 接受输入事件来自两种不同的来源:输入源(inputsource)和 定时源(timer source)输入源 传递异步事件,通常消息来自于其它线程和程序。定时源 则传递同步事件,发生在特定时间或者重复的时 阅读全文
posted @ 2012-05-04 23:16 高笑228 阅读(111) 评论(0) 推荐(0)