rexis.cn

一张相片 一段故事

在iphone app中添加音量控制条

without comments

1. 添加MediaPlayer.framework
2. #import <MediaPlayer/MPVolumeView.h>
3. 代码

	MPVolumeView *volumeView = [[[MPVolumeView alloc]  initWithFrame:CGRectMake(18, 380, 284, 23)] autorelease];
	volumeView.center = CGPointMake(160,380);
	[volumeView sizeToFit];
	[self.view addSubview:volumeView];

Written by 北

七月 2nd, 2010 at 12:25 下午

Posted in iphone开发

Tagged with , ,

iphone程序中跳转到appstore评论界面

without comments

在程序中加入appstore的review跳转,实现方法很简单,就是让系统去打开一个review的链接,代码如下:

- (void) gotoWriteReviews {
	NSString* appID = NSLocalizedString(@"itunesconnect_appid", nil);	//这里是itunes connect生成的一串数字id
	NSString *u = [NSString stringWithFormat:@"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=%@&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software",appID];
	[[UIApplication sharedApplication] openURL:[NSURL URLWithString:u]];
}

Written by 北

五月 25th, 2010 at 12:13 下午

Posted in iphone开发

Tagged with , ,

在图片上盖一层mask

without comments

- (UIImage*) createImage:(UIImage*)_image withMask:(UIImage*)_mask {
	CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
	CGContextRef context = CGBitmapContextCreate(NULL,
						 _image.size.width,
						 _image.size.height,
						 8, 0,
						 colorSpace,
						kCGImageAlphaPremultipliedLast);
	CGColorSpaceRelease(colorSpace);
 
	CGRect rect = CGRectMake(0, 0, _image.size.width, _image.size.height);
	UIColor *bColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1];
	CGContextSetFillColorWithColor(context, [bColor CGColor]);                     //黑色是不透明,白色是透明
	CGContextFillRect(context, rect);
	CGContextClipToMask(context, rect, [_mask CGImage]);
	CGContextDrawImage(context, rect, [_image CGImage]);
 
	CGImageRef newImage = CGBitmapContextCreateImage(context);
	CGContextRelease(context);
 
	UIImage* _newImage = [[UIImage alloc] initWithCGImage:newImage];
	CGImageRelease(newImage);
 
	return [_newImage autorelease];
}

最先创建了一个灰度的颜色空间导致合成出来的mask颜色都是反的,黑色的显出白色,后来发现一篇例子是用RGB颜色空间来做再自己加上黑色填充后就得到了想要的效果,效果图:
lomo效果

Written by 北

五月 20th, 2010 at 11:59 下午

Posted in iphone开发

Tagged with , , ,

土比的聚餐会

without comments

昨天公司聚餐,一伙人把一小店挤的满满当当,一坐下我就觉得特悲惨,但是更悲惨的我认为是旁边的一对日本老夫妇。。莫名其妙出现一大帮人,还那么大声喧哗。
中间过程略过,到最后高潮。。个个都已经喝的快吐的和已经吐过的硬要在那划出两帮派分高低。白酒跟白开水一样灌,虽然满high,但是结局很惨烈。电车上出租车上吐得到处都是,更惨烈的是我这个没吐的得在旁边接受路人鄙视的眼神。
这一回,也算在小日本地盘上丢了一回脸。

Written by 北

十一月 29th, 2009 at 2:28 下午

Posted in life

2009.11.18

without comments

记忆力越来越差 很多时候都会被突如其来的问题 把脑子塞住
会不会某一天突然变的今天不记得明天的事… 就跟某个日剧中的人物一样 需要不停的记录下见过的人 做过的事

Written by 北

十一月 18th, 2009 at 7:23 上午

Posted in life

在UIViewController中用多线程更新UI的异常

without comments

在UIViewController中用多线程时,如果该线程方法中有更新UI操作的话,会抛出如下错误:

Tried to obtain the web lock from a thread other than the main thread or the web thread.
This may be a result of calling to UIKit from a secondary thread. Crashing now…

貌似是因为UIKit是非线程安全的,所以更新UI只能在主线程中操作,解决的办法:

- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait

用该方法指定要执行的UI更新Method在主线程中执行.

Written by 北

十一月 15th, 2009 at 9:06 上午

Posted in program

2009.11.14

without comments

夕阳

昏昏沉沉

一觉醒来后

发现阳台外一片落日余晖

马上拿出相机记录下了

Written by 北

十一月 14th, 2009 at 2:25 上午

Posted in life

dreamhost上装上了django

without comments

新买的dreamhost的虚拟主机 成功编译了python并安上了django

按下面的文章一步一步做的 基本和dh的wiki上一样

http://www.lostk.com/blog/configure_python_and_django_on_dreamhost/

Written by 北

十月 17th, 2009 at 7:08 上午

Posted in 未分类

Tagged with , ,

北海道乘车计划

without comments

第一天(2009.09.19)出发日 为了省钱和看看沿途的景色 选择了坐普通电车

过程十分漫长而艰巨 请看图
在福岛有差不多半小时左右等车时间 可以出车站吃点东西 之后继续上路

去北海道电车第一阶段

在青森稍作修整后继续出发并在电车上过夜

去北海道电车第二阶段

由于为了后面的行程考虑 我们把北海道的第一站定在了小樽而略去了函馆(话说函馆的夜景那是相当牛逼的)
时间跨度上到小樽(2009.09.20)已经是第二天 经过一天一夜的长途电车奔波 第二天的观光将会是可以想象的艰辛。。。

Written by 北

九月 13th, 2009 at 4:38 下午

Posted in life

json for objective-c

without comments

一个json对象和NSDictionary对象相互转换的framework

project home:
http://code.google.com/p/json-framework/

Written by 北

八月 18th, 2009 at 9:26 上午

Posted in program

Tagged with