iOS学习笔记

快捷方式查询Xcode的苹果开发文档:

command+shift+0

 

工程中使用PCH文件时,需在targets—>Build Settings—>Prefix Header项加入相对路径$(PROJECT_DIR)/$(PROJECT_NAME)/PrefixHeader.pch

 

 

 

邮件

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://devprograms@apple.com"]];

电话

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8004664411"]];

sms

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://466453"]];

浏览器

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunesconnect.apple.com"]]; 

 

 

 

*****************************************************************颜色处理******************************************************************

#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

 

 

***********************获取手机iOS系统的版本号******************************

[[[UIDevice currentDevice] systemVersion] floatValue]

 

获取手机的唯一标示符 

NSString *str = [UIDevice currentDevice].identifierForVendor.UUIDString;

 NSLog(@"%@",str);

 

[[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString]; 

 

一、使用advertisingIdentifier步骤

1、添加框架

AdSupport.framework

2、添加头文件

#import <AdSupport/ASIdentifierManager.h>

3、使用语句

NSString *adId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];

***********************隐藏状态栏******************************

- (UIStatusBarStyle)preferredStatusBarHiden

{

    return YES;

}

 

 

 

**********************取消tableView的cell的选中状态**************************

 [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];

 

 

 

*********************AFNetworking清除缓存*************************

//显示缓存大小

NSInteger size = [[NSURLCache sharedURLCache] currentMemoryUsage];

 

        //字节要转化为M

        CGFloat fileSize = size/1024.0/1024.0;

        UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:[NSString stringWithFormat:@"缓存大小:%.3fM",fileSize] delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles: nil];

        [sheet showInView:self.view];

 

//代理方法清除缓存

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

{

    if (buttonIndex == actionSheet.destructiveButtonIndex)

    {

        [[NSURLCache sharedURLCache] removeAllCachedResponses];

    }

 

}

 

*********************tableView的cell的分割线从顶端(最左端)开始*************************

- (void)viewDidLayoutSubviews{

    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {

        [self.tableView setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];

    }

    if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {

        [self.tableView setLayoutMargins:UIEdgeInsetsMake(0, 0, 0, 0)];

    }

}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {

        [cell setSeparatorInset:UIEdgeInsetsZero];

    }

    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {

        [cell setLayoutMargins:UIEdgeInsetsZero];

    }

 

}

 

***********改变webView的字体大小********************

- (void)webViewDidFinishLoad:(UIWebView *)webView{

    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

    

    NSString *str =[NSString stringWithFormat: @"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '%@%%'",@(250)];

    [_webView stringByEvaluatingJavaScriptFromString:str];

    

 

}

 

***********webView加载git动画********************

NSString *path = [[NSBundle mainBundle] pathForResource:@"happy" ofType:@"gif"];

    //将图片转为NSData

    NSData *gifData = [NSData dataWithContentsOfFile:path];

    //自动调整尺寸

    _webView.scalesPageToFit = YES;

    //禁止滚动

    _webView.scrollView.scrollEnabled = NO;

    //设置透明效果

    _webView.backgroundColor = [UIColor clearColor];

    _webView.opaque = 0;

    //加载数据

    [_webView loadData:gifData MIMEType:@"image/gif" textEncodingName:nil baseURL:nil];

 

 

 

 

 

#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

posted @ 2015-11-06 10:40  Mr_tao  阅读(225)  评论(0编辑  收藏  举报