转载2
2012-04-28 11:43 java环境变量 阅读(209) 评论(0) 编辑 收藏 举报 CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:0.35];
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
if (!curled){
animation.type = @"pageCurl";
animation.fillMode = kCAFillModeForwards;
animation.endProgress = 0.40;
} else {
animation.type = @"pageUnCurl";
animation.fillMode = kCAFillModeBackwards;
animation.startProgress = 0.30;
}
[animation setRemovedOnCompletion:NO];
[self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[self.view.layer addAnimation:animation forKey:@"pageCurlAnimation"];
UIImageView *imgvPhoto = [UIImageView alloc] init];
//添加边框
CALayer *layer = [_imgvPhoto layer];
layer.borderColor = [[UIColor whiteColor] CGColor];
layer.borderWidth = 5.0f;
//添加四个边阴影
_imgvPhoto.layer.shadowColor = [UIColor blackColor].CGColor;
_imgvPhoto.layer.shadowOffset = CGSizeMake(0, 0);
_imgvPhoto.layer.shadowOpacity = 0.5;
_imgvPhoto.layer.shadowRadius = 10.0;
//添加两个边阴影
_imgvPhoto.layer.shadowColor = [UIColor blackColor].CGColor;
_imgvPhoto.layer.shadowOffset = CGSizeMake(4, 4);
_imgvPhoto.layer.shadowOpacity = 0.5;
_imgvPhoto.layer.shadowRadius = 2.0;
viewDidLoad事件中,增加一个图片及定时器并启动,这里的pic请在头文件中定义。
-(void)viewDidLoad{
[super viewDidLoad];
self.pic = [UIImage imageNamed:@"snow.png"];//初始化图片
//启动定时器,实现飘雪效果
[NSTimer scheduledTimerWithTimeInterval:(0.2) target:self selector:@selector(ontime) userInfo:nil repeats:YES];
}
然后再实现定时器定时调用的ontime方法:
-(void)ontime{
UIImageView *view = [[UIImageView alloc] initWithImage:pic];//声明一个UIImageView对象,用来添加图片
view.alpha = 0.5;//设置该view的alpha为0.5,半透明的
int x = round(random()20);//随机得到该图片的x坐标
int y = round(random()20);//这个是该图片移动的最后坐标x轴的
int s = round(random())+10;//这个是定义雪花图片的大小
int sp = 1/round(random()0)+1;//这个是速度
view.frame = CGRectMake(x, -50, s, s);//雪花开始的大小和位置
[self.view addSubview:view];//添加该view
[UIView beginAnimations:nil context:view];//开始动画
[UIView setAnimationDuration:10*sp];//设定速度
view.frame = CGRectMake(y, 500, s, s);//设定该雪花最后的消失坐标
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
}
1、在xcode中的左侧目录中找到Executables 打开
2、双击和工程名一样的文件。
3、在打开的文件中的Arguments选项,在下面的框中加入Name: NSZombieEnabled 设置value为YES。
-(void)addEmail{
Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil){
if ([mailClass canSendMail]){
[self displayComposerSheet];
}else{
[self launchMailAppOnDevice];
}
}else{
[self launchMailAppOnDevice];
}
}
-(void)displayComposerSheet
{
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.navigationBar.tag = 1002;
[self.navigationController.navigationBar setNeedsDisplay];
controller.mailComposeDelegate = self;
[controller setSubject:@"意见反馈"];
[controller setToRecipients:[[NSArray alloc] initWithObjects:@"555@cifco.net.cn",nil]];
NSString *emailBody = nil;
[controller setMessageBody:emailBody isHTML:YES];
[self presentModalViewController:controller animated:YES];
[controller release];
}
#pragma mark mailComposeDelegate ----
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
if (result == MFMailComposeResultSent)
{
[self dismissModalViewControllerAnimated:YES];
}
if (result == MFMailComposeResultSaved)
{
[self dismissModalViewControllerAnimated:YES];
}
if (result == MFMailComposeResultFailed)
{
Emailalert = [[UIAlertView alloc] initWithTitle:@"" message:@"发送失败" delegate:selfcancelButtonTitle:@"知道了" otherButtonTitles:nil];
[Emailalert show];
}
if (result == MFMailComposeResultCancelled)
{
[self dismissModalViewControllerAnimated:YES];
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(alertView == Emailalert)
{
if (buttonIndex == )
{
[self dismissModalViewControllerAnimated:YES];
}
}else
{
if (buttonIndex == )
{
//[self dismissModalViewControllerAnimated:YES];
}else
{
NSString *recipients = @"mailto:theonelgq@gmail.com?cc=theone_liuguoqing@163.com&subject=text";
NSString *body = @"&body=text!";
NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body];
email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
}
}
}
#pragma mark -
#pragma mark Workaround
-(void)launchMailAppOnDevice
{
isEmailalert = [[UIAlertView alloc] initWithTitle:@"警告" message:@"请配置您的邮箱" delegate:selfcancelButtonTitle:@"取消" otherButtonTitles:@"好的",nil];
[isEmailalert show];
}
iOS设备现在有三种不同的分辨率:iPhone 320x480、iPhone 4 640x960、iPad 768x1024。以前程序的启动画面(图片)只要准备一个 Default.png 就可以了,但是现在变得复杂多了。下面就是 CocoaChina 会员做得总结
如果一个程序,既支持iPhone又支持iPad,那么它需要包含下面几个图片:
Default-Portrait.png iPad专用竖向启动画面 768x1024或者768x1004
Default-Landscape.png iPad专用横向启动画面 1024x768或者1024x748
Default-PortraitUpsideDown.png iPad专用竖向启动画面(Home按钮在屏幕上面),可省略 768x1024或者768x1004
Default-LandscapeLeft.png iPad专用横向启动画面,可省略 1024x768或者1024x748
Default-LandscapeRight.png iPad专用横向启动画面,可省略 1024x768或者1024x748
Default.png iPhone默认启动图片,如果没有提供上面几个iPad专用启动图片,则在iPad上运行时也使用Default.png(不推荐) 320x480或者320x460
Default@2x.png iPhone4启动图片640x960或者640x920
为了在iPad上使用上述的启动画面,你还需要在info.plist中加入key: UISupportedInterfaceOrientations。同时,加入值UIInterfaceOrientationPortrait, UIInterfacOrientationPortraitUpsideDown, UIInterfaceOrientationLandscapeLeft, UIInterfaceOrientationLandscapeRight
- (IBAction)URLFetchWithProgress:(id)sender
{
[startButton setTitle:@"Stop" forState:UIControlStateNormal];
[startButton addTarget:self action:@selector(stopURLFetchWithProgress:)forControlEvents:UIControlEventTouchUpInside];
NSString*tempFile = [[[[NSBundle mainBundle] bundlePath]stringByDeletingLastPathComponent]stringByAppendingPathComponent:@"MemexTrails_1.0b1.zip.download"];
if ([[NSFileManager defaultManager] fileExistsAtPath:tempFile]) {
[[NSFileManager defaultManager] removeItemAtPath:tempFile error:nil];
}
[self resumeURLFetchWithProgress:self];
}
- (IBAction)stopURLFetchWithProgress:(id)sender
{
networkQueue = [[ASINetworkQueue alloc] init];
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:selfselector:@selector(updateBandwidthUsageIndicator) userInfo:nil repeats:YES];
timer = nil;
[startButton setTitle:@"Stop" forState:UIControlStateNormal];
[startButton addTarget:self action:@selector(URLFetchWithProgress:)forControlEvents:UIControlEventTouchUpInside];
[networkQueue cancelAllOperations];
[resumeButton setEnabled:YES];
}
- (IBAction)resumeURLFetchWithProgress:(id)sender
{
[resumeButton setEnabled:NO];
[startButton setTitle:@"Start" forState:UIControlStateNormal];
[startButton addTarget:self action:@selector(stopURLFetchWithProgress:)forControlEvents:UIControlEventTouchUpInside];
[networkQueue cancelAllOperations];
[networkQueue setShowAccurateProgress:YES];
[networkQueue setDownloadProgressDelegate:progressIndicator];
[networkQueue setDelegate:self];
[networkQueue setRequestDidFinishSelector:@selector(URLFetchWithProgressComplete:)];
ASIHTTPRequest*request=[[[ASIHTTPRequest alloc] initWithURL:[NSURLURLWithString:@"http://9991.net/blog/mp3/2.mp3"]] autorelease];
[request setDownloadDestinationPath:[[[[NSBundle mainBundle] bundlePath]
stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"MemexTrails_1.0b1.mp3"]];
[request setTemporaryFileDownloadPath:[[[[NSBundle mainBundle] bundlePath]stringByDeletingLastPathComponent]stringByAppendingPathComponent:@"MemexTrails_1.0b1.zip.down"]];
[request setAllowResumeForFileDownloads:YES];
[networkQueue addOperation:request];
[networkQueue go];
}
- (void)URLFetchWithProgressComplete:(ASIHTTPRequest *)request
{
if ([request error]) {
fileLocation.text=[NSString stringWithFormat:@"An error occurred:%@",[[[requesterror] userInfo] objectForKey:@"Title"]];
} else {
fileLocation.text=[NSString stringWithFormat:@"File downloaded to %@",[requestdownloadDestinationPath]];
}
[startButton setTitle:@"Start" forState:UIControlStateNormal];
[startButton addTarget:self action:@selector(URLFetchWithProgress:)forControlEvents:UIControlEventTouchUpInside];
}
- (IBAction)throttleBandwidth:(id)sender
{
if ([(UIButton *)sender state] ==YES) {
[ASIHTTPRequest setMaxBandwidthPerSecond:ASIWWANBandwidthThrottleAmount];
} else {
[ASIHTTPRequest setMaxBandwidthPerSecond:];
}
}
在plist文件中加入URL types 结构如下图,在Safari中地址栏输入 设置的字符串,比如设置的是
QQ,地址栏输入 QQ:// 就可以起点本地应用。
#pragma mark -
#pragma mark UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
UIView *touchView = touch.view;
if ([touchView isKindOfClass:[UISlider class]])
{
return NO;
}
else
{
return YES;
}
}
NSString *cookieString = [NSString stringWithString:[headers objectForKey:@"Cookie"]];
NSMutableDictionary *cookieProperties = [[NSMutableDictionary alloc] init];
[cookieProperties setValue:cookieString forKey:NSHTTPCookieValue];
[cookieProperties setValue:@"QQCookie" forKey:NSHTTPCookieName];
[cookieProperties setValue:@".QQ.com" forKey:NSHTTPCookieDomain];
[cookieProperties setValue:[NSDate dateWithTimeIntervalSinceNow:60*60] forKey:NSHTTPCookieExpires];
[cookieProperties setValue:@"/" forKey:NSHTTPCookiePath];
NSHTTPCookie *newcookie = [[NSHTTPCookie alloc] initWithProperties:cookieProperties];
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:newcookie];