转载2

转载2,第1张

概述11、谷歌地图翻起动画效果     CATransition *animation = [CATransition animation];     [animation setDelegate:self];     [animation setDuration:0.35];     [animation setTimingFunction:UIViewAnimationCurveEaseInOut 11、谷歌地图翻起动画效果

    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"];

12、给View添加阴影 和边框

UIImageVIEw *imgvPhoto  = [UIImageVIEw alloc] init];

//添加边框

   CALayer *layer = [_imgvPhoto layer];     layer.bordercolor = [[UIcolor whitecolor] CGcolor];     layer . cornerRadius  =  5 ;
    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;

13、使用NSTimer与UIView动画实现飘雪效果

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);//设定该雪花最后的消失坐标
 [UIVIEw setAnimationDelegate:self];
 [UIVIEw commitAnimations];
}

14、配置Xcode 看程序崩溃信息

1、在xcode中的左侧目录中找到Executables 打开

2、双击和工程名一样的文件。

3、在打开的文件中的Arguments选项,在下面的框中加入name: NSZombIEEnabled 设置value为YES。

15、程序中发送邮件和检测设备邮箱是否被配置

-(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:@"[email protected]",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) 

if (result == MFMailComposeResultFailed) 

Emailalert = [[UIAlertVIEw alloc] initWithTitle:@"" message:@"发送失败" delegate:selfcancelbuttonTitle:@"知道了" otherbuttonTitles:nil];

[Emailalert show];

if (result == MFMailComposeResultCancelled) 

- (voID)alertVIEw:(UIAlertVIEw *)alertVIEw clickedbuttonAtIndex:(NSInteger)buttonIndex

if(alertVIEw == Emailalert)

if (buttonIndex == ) 

}else 

//[self dismissModalVIEwControllerAnimated:YES];

Nsstring *recipIEnts = @"mailto:[email protected][email protected]&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];

}

16、程序启动画面大小

 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

[email protected] iPhone4启动图片640x960或者640x920

  为了在iPad上使用上述的启动画面,你还需要在info.pList中加入key: UISupportedInterfaceOrIEntations。同时,加入值UIInterfaceOrIEntationPortrait,UIInterfacOrIEntationPortraitUpsIDeDown,UIInterfaceOrIEntationLandscapeleft,UIInterfaceOrIEntationLandscapeRight

17、ASIHTTPRequest实现断点下载

- (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 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 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]];

- (IBAction)throttleBanDWIDth:(ID)sender

if ([(UIbutton *)sender state] ==YES) {

[ASIhttpRequest setMaxBanDWIDthPerSecond:ASIWWANBanDWIDthThrottleAmount];

[ASIhttpRequest setMaxBanDWIDthPerSecond:];

}

18、Safari 启动本地app

在pList文件中加入URL types 结构如下图,在Safari中地址栏输入 设置的字符串,比如设置的是

QQ,地址栏输入 QQ:// 就可以起点本地应用。

 

19、拖到视频进度与滑动手势冲突解决办法

#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;
    }
}

20、创建并保存Cookie的方法


        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];

//判断机型

    #import <sys/utsname.h>

    uname(&systemInfo);

    Nsstring *dev = [Nsstring stringWithCString:systemInfo.machine enCoding:NSUTF8StringEnCoding];

总结

以上是内存溢出为你收集整理的转载2全部内容,希望文章能够帮你解决转载2所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1091567.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存