func blurImage(value:NSNumber) -> UIImage {html
let context = CIContext(options:[KCIContextUseSoftwareRenderer:true])ios
let ciImage = CoreImage.CIImage(image:self)git
let blurFilter = CIFilter(name:"CIGassianBlur")程序員
blurFilter?.setValue(ciImage, forKey:KCIInputImageKey)github
blurFilter?.setValue(value, forKey:"inputRadius")web
let imageRef = context.createCGImage((blurFilter?.outputImage)!, fromRect:(ciImage?.extent)!)objective-c
let newImage = UIImage(CGImage:imageRef)數據庫
return newImagejson
}swift
value : value表明毛玻璃效果的程度
核心內容:let blurFilter = CIFilter(name:"CIGassianBlur") 使用濾鏡工具
func imageCompress(targetWidth:CGFloat) -> UIIMage {
let targetHeight = targetWidth/width*height
UIGraphicsBeginImageContext(CGSizeMake(targetWidth,targetHeight))
self.drawInRect(CGRectMake(0,0,targetWidth,targetHeight))
let newImage:UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGrapicsEndImageContext()
return newImage
}
這裏是按原UIImage比例作壓縮因此:let targetHeight = targetWidth/width*height
一:SVN
A. 項目經理:1.建立項目—CheckIn
2.設置項目人員
B.工做人員:1.CheckOut 獲取項目的完整副本,此工做只須要作"一次"
2. 工做寫代碼....
3.階段性工做完成後,Commit(提交) 將本身修改的文件,上傳到服務器
天天下班前必定要作一次可以編譯的提交!
4.按期Update項目,從服務器將最新的內容更新到本地,天天上班第一件事情必定要作的事情!
二. Git
A.項目經理:1.建立項目push
2.設置項目人員
B. 工做人員:1.Pull從服務器下拉最新的本版
2.Commit是將修改過的代碼提交至本地的代碼庫
3.天天下班前Push本身當前的代碼到服務器
4.天天上班前從服務器Pull最新的內容
三. M / A 文件更新
對於文件夾svn支持並很差,須要在工具下選定文件夾commit
對應文件選定文件commits
因爲過去在公司多半時間是作獨立開發,最多人的時候也是兩我的作開發,因此協做工具用的少,可是不斷的關注着兩種代碼倉庫管理工具,總結了一些tip,還有待實踐驗證,吐槽吧......
iOS 9 前:
navigationBar 若是設置了背景圖片,那麼可視化座標會從navgationbar下面開始
self.navigationController?.navigationBar.setBackgroundImage(UIImage(named:"nav"), forBarMetrics:UIBarMetrics.Default)
iOS 9 後 : 座標從狀態欄下面開始
const char *cString = "CString";
C字符串轉成NSString : NSString *str = [NSString stringWithUTF8String:cString];
NSString * str = @"NSString";
NSString轉成C字符串 : const char *cString = [str UTF8String];
Objective-C :
UILabel *label1 = ({
UILabel *label = [UILabelnew];
[self.view addSubview:label];
label.frame=CGRectMake(100,100,100,45);
label.backgroundColor= [UIColor redColor];
label.text=@"你們好1";
label;
});
UILabel*label2 = ({
UILabel*label = [UILabel new];
[self.view addSubview:label];
label.frame=CGRectMake(100,160,100,45);
label.backgroundColor= [UIColor redColor];
label.text=@"你們好2";
label;
});
UILabel*label3 = ({
UILabel*label = [UILabel new];
label.frame=CGRectMake(100,250,100,45);
label.backgroundColor= [UIColor redColor];
label.text=@"你們好3";
label;
});
[self.viewaddSubview:label3];
({
UILabel *label = [UILabel new];
[self.view addSubview:label];
label.frame=CGRectMake(100,310,100,45);
label.backgroundColor= [UIColor redColor];
label.text=@"你們好4";
});
Swift:
letlabel1:UILabel= {
let label =UILabel()
self.view.addSubview(label)
label.frame=CGRectMake(100,100,100,45)
label.backgroundColor=UIColor.redColor()
label.text="你們好"
return label
}()
let label2:UILabel= {
let label =UILabel()
label.frame=CGRectMake(100,200,100,45)
label.backgroundColor=UIColor.redColor()
label.text="你們好"
return label
}()
self.view.addSubview(label2)
使用語法糖的好處就是拷貝代碼時只需作少量的修改就能夠達到目的,如上面的栗子,想要建立多個label,只要賦值粘貼,改一處,也就是對象名稱就能夠輕鬆完成!
數據緩存方式選擇:
1: fmdata數據庫(增刪改查) --數據須要:增刪改查
2: coreData --數據須要:增刪改查
3:序列化(NSUserDefault) --狀態、偏好設置、默認選項
4:單獨.plist --列表數據,城市信息等
5:單獨.json文件 --頁面列表數據
6: realm框架(增刪改查) --數據須要:增刪改查
7: FastCoder 某「強哥」推薦,哈哈哈!
~/Library/MobileDevice/Provisioning Profiles
因爲平時會負責多個項目的上線管理或是開發工做,所以MAC中有不少簽名文件,有時候都分不清東西南北,一不作,二不休,前往這個目錄下,將文件刪個精光,調試的時候用到證書再update一下當前項目的證書便可
Objective-c版本:
- (UIViewController *)getAppRootViewController
{
UIViewController *appRootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
UIViewController *topVC = appRootVC;
while (topVC.presentedViewController) {
topVC = topVC.presentedViewController;
}
return topVC;
Swift版本:
func getAppRootViewController() -> UIViewController? {
var topVC = UIApplication.sharedApplication().keyWindow?.rootViewController
while topVC?.presentedViewController != nil {
topVC = topVC?.presentedViewController
}
return topVC?
}
步驟:
一、新建iOS->Other->PCH File
二、targets->BuildSetting->Prefix Header->設置$(SRCROOT)/文件在工程中的路徑
三、pch能像之前同樣正常使用
如:$(SRCROOT)/FirstProject/PrefixHeader.pch
FirstProject : pch路徑中的最後一個拓展名
PrefixHeader.pch: 是pch文件名
簡介:/Users/ly/Desktop/FirstProject/FirstProject
當 UIViewController做爲UINavigationController的根視圖控制器的時候,將這個Nav(root)賦給 tabBarController時,
這樣寫:
root.title = @「title」;
那麼 :self.naviagtionItem.title 會顯示 title
同時 :nav.tabBarItem.title 也會顯示 title
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer {
if([gestureRecognizerisKindOfClass:[UIPanGestureRecognizerclass]]) {
CGPointvelocity = [(UIPanGestureRecognizer*)gestureRecognizervelocityInView:gestureRecognizer.view];
BOOLisHorizontalPanning =fabsf(velocity.x) >fabsf(velocity.y);
return isHorizontalPanning;
}
returnYES;
}
github上搜: UIViewController+BackButtonHandler 開源項目
self.view.backgroundColor=UIColor(colorLiteralRed:255.0/255, green:255.0/255, blue:255.0/255, alpha:0.3)
let subView = UIView()
subView.tintColor=UIColor.whiteColor()//不透明瞭
self.view.addSubview(subView)
// 從ipod庫中讀出音樂文件
MPMediaQuery *everything = [[MPMediaQuery alloc] init];
// 讀取條件
MPMediaPropertyPredicate *albumNamePredicate = [MPMediaPropertyPredicate predicateWithValue:[NSNumber numberWithInt:MPMediaTypeMusic] forProperty: MPMediaItemPropertyMediaType];
[everything addFilterPredicate:albumNamePredicate];
NSLog(@"Logging items from a generic query...");
NSArray *itemsFromGenericQuery = [everything items];
for (MPMediaItem *song in itemsFromGenericQuery) {
NSString *songTitle = [song valueForProperty: MPMediaItemPropertyTitle];
NSLog (@"%@", songTitle);
}
1.如何識別一個應用安裝在同一個設備上呢?
2.如何識別一個企業的應用安裝在同一個設備上呢?
蘋果給咱們提供了advertisingIdentifier 來解決問題1;
只要是同一臺設備,那麼advertisingIdentifier就是同樣的
可是若是在設置-隱私-廣告那裏關掉這個權限或是還原設備的話,就沒辦法了哭死去吧
蘋果給咱們提供了identifierForVendor 來做爲一個企業的app標示符
好比: com.game.yoyo
com.game.xoxo
只要在同一臺設備上,那麼identifierForVendor 是同樣的
若是:com.game.yoyo
com.buyer.yoyo
無論是否是同一個應用identifierForVendor 都是不同的
上代碼:
廣告id:
#import
//每一個設備有惟一一個,若是重置廣告或設置-隱私-關閉廣告就會關閉更換
NSString*adId = [[[ASIdentifierManagersharedManager]advertisingIdentifier]UUIDString];
企業id:
NSString*idfv = [[[UIDevicecurrentDevice]identifierForVendor]UUIDString];
因爲簡書的一些限制,不能粘貼文件,考慮選擇一個方式將我本身的實踐工程放出來,之後持續更新
(MAC下搭建服務器+證書製做+推送測試)
#import"VolumeSetter.h"
#import
@implementationVolumeSetter
{
MPVolumeView*volumeView;
UISlider* volumeViewSlider;
}
+ (instancetype)shareInstance
{
staticVolumeSetter*vs;
staticdispatch_once_tonce;
dispatch_once(&once, ^{
vs = [[VolumeSetteralloc]init];
});
returnvs;
}
- (void)setVolume:(float)value
{
[self getSlider];
[volumeViewSlidersetValue:valueanimated:NO];// send UI control event to make the change effect right now.
[volumeViewSlidersendActionsForControlEvents:UIControlEventTouchUpInside];
}
- (float)getVolume:(volumeBlock)handel
{
_myHandel= handel;
[selfgetSlider];
returnvolumeViewSlider.value;
}
- (MPVolumeView*)getVolumeView
{
if(volumeView==nil) {
volumeView= [[MPVolumeViewalloc]init];
[[NSNotificationCenterdefaultCenter]addObserver:self
selector:@selector(volumeChanged:)
name:@"AVSystemController_SystemVolumeDidChangeNotification"
object:nil];
}
returnvolumeView;
}
- (UISlider*)getSlider
{
[selfgetVolumeView];
for(UIView*viewin[volumeViewsubviews]){
if([view.class.descriptionisEqualToString:@"MPVolumeSlider"]){
volumeViewSlider= (UISlider*)view;break;
}
}
returnvolumeViewSlider;
}
- (void)volumeChanged:(NSNotification*)notification
{
floatvolume =
[[[notificationuserInfo]
objectForKey:@"AVSystemController_AudioVolumeNotificationParameter"]
floatValue];
NSLog(@"current volume = %f", volume);
_myHandel(volume);
}
@end
http://www.cocoachina.com/ios/20151110/14102.html
待補充
1. push 以前
// back title
self.navigationItem.backBarButtonItem=UIBarButtonItem(title:"返回", style:UIBarButtonItemStyle.Plain, target:nil, action:nil)
// 特別注意:在push以前設置
self.navigationController?.pushViewController(vc, animated:true)
2.設置顏色
self.navigationController?.navigationBar.tintColor=UIColor.blackColor()
總結:
self.navigationItem.backBarButtonItem=UIBarButtonItem(title:"返回", style:UIBarButtonItemStyle.Plain, target:nil, action:nil)
self.navigationController?.navigationBar.tintColor=UIColor.blackColor()
self.navigationController?.pushViewController(vc, animated:true)
Swift : https://github.com/raywenderlich/swift-style-guide#use-of-self
OC : https://github.com/raywenderlich/objective-c-style-guide
Person類:
@interfacePerson :NSObject
@property(nonatomic) NSUIntager age;
@property(nonatomic,copy)NSString*name;
@end
#import"Person.h"
@implementationPerson
- (NSString*)description
{
return[NSStringstringWithFormat:@"age=%d,name=%@",self.age,self.name];
}
@end
ViewController.m類:
Person*p1 = [[Personalloc]init];
p1.age=15;
p1.name=@"張三";
Person*p2 = [[Personalloc]init];
p2.age=25;
p2.name=@"小米";
Person*p3 = [[Personalloc]init];
p3.age=15;
p3.name=@"李四";
NSArray*arr =@[p1,p2,p3];
//謂詞
NSPredicate*pre = [NSPredicatepredicateWithFormat:@"%K==%d || %K==%@ || %K=%@",@"age",15,@"name",@"張三",@"name",@"李四"];
arr = [arrfilteredArrayUsingPredicate:pre];
NSLog(@"%@",arr);
輸出:
2015-12-08 11:24:05.862 Predicate[12080:634959] (
"age=15,name=\U5f20\U4e09",
"age=15,name=\U674e\U56db"
)
用於作查詢操做很是棒,避免寫一大堆的if else操做
VVDocumenter 是一個比較好用的註釋控件
Alcatraz(插件管理器)http://www.tuicool.com/articles/v2eIVb
https://github.com/supermarin/Alcatraz
Xcode 6.4找不到packageManager :http://blog.csdn.net/yimu520csdn/article/details/47040041
方法一:
- (BOOL)application:(UIApplication*)application handleOpenURL:(NSURL*)url
{
return [WXApihandle OpenURL:urldelegate:self];
}
方法二:
- (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation
{
return[WXApihandle OpenURL:url delegate:self];
}
今天作微信登錄功能,隨手寫一個demo,沒有設置bundle id , display name,結果就不走 方法一,方法二
致使下面兩個代理方法不走
- (void) onReq:(BaseReq*)req{
NSLog(@"xxxxxxxx");
}
- (void) onResp:(BaseResp*)resp{
NSLog(@"fffffffff");
}
解決方法:設置Bundle identifier 以及 Bundledisplayname ,注意要與註冊獲取appid secret key 時所填的保持一致.
固然其餘設置也要保證設置上,好比 URL sechme , iOS9 注意適配 ATS,添加白名單
現象:
升級到iOS7後,UIStatusBar的出現致使現有UI界面亂掉了。
緣由:
因爲寫死了某些控件的絕對位置,原先隱藏UIStatusBar的代碼沒有在iOS7中起做用
解決方法:
iOS7如下版本隱藏UIStatusBar的方法:
- (BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
[application setStatusBarHidden:YES];
returnYES;
}
升級到iOS7後的方法:
在基類中重載UIViewController.h中的這個方法
- (BOOL)prefersStatusBarHidden NS_AVAILABLE_IOS(7_0);// Defaults to NO
- (BOOL)prefersStatusBarHidden
{
return YES;
// iOS7後如下方法已經不起做用: [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
}
UIColor*color = [UIColorcolorWithRed:0.0green:0.0blue:1.0alpha:1.0];
constCGFloat*components =CGColorGetComponents(color.CGColor);
NSLog(@"Red: %f", components[0]);
NSLog(@"Green: %f", components[1]);
NSLog(@"Blue: %f", components[2]);
iOS開發-簡單圖片背景替換(實現摳圖效果)
http://www.tuicool.com/articles/VZN3yiZ
在命令行工具輸入 $ uuidgen : 8-4-4-4-12
https://github.com/huang303513/Design-Pattern-For-iOS
發佈APP要求,不能使用Beta版本的Xcode
若是一個開發團隊裏面有多個小夥伴,不要爲了嘗新將全部的Mac OX 或是Xcode都升級到Beta版本,應該由一個小夥伴進行測試感覺新版本是否穩定,是否有坑,否認後果很嚴重,說多都是淚,您想一想:從新裝系統,從新下載Xcode是一件多麼苦逼的事情。。。
這是抄自項目裏面的一段代碼,若是您要用到判斷UIScrollView向左仍是向右的滾動邏輯,請先定義相關狀態的全局變量
-(void)scrollViewWillBeginDragging:(UIScrollView*)scrollView
{
startContentOffsetX= scrollView.contentOffset.x;
}\
- (void)scrollViewWillEndDragging:(UIScrollView*)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inoutCGPoint*)targetContentOffset{//將要中止前的座標
willEndContentOffsetX= scrollView.contentOffset.x;
}
- (void)scrollViewDidEndDecelerating:(UIScrollView*)scrollView{
endContentOffsetX= scrollView.contentOffset.x;
if(endContentOffsetX < willEndContentOffsetX && willEndContentOffsetX < startContentOffsetX) {
NSLog(@"畫面從右往左移動,前一頁");
}else if(endContentOffsetX > willEndContentOffsetX&&
willEndContentOffsetX > startContentOffsetX) {
NSLog(@"畫面從左往右移動,後一頁");
}
}
引入:CoreTelephony.framework
extern NSString*constkCTSMSMessageReceivedNotification;
extern NSString*constkCTSMSMessageReplaceReceivedNotification;
extern NSString*constkCTSIMSupportSIMStatusNotInserted;
extern NSString*constkCTSIMSupportSIMStatusReady;
id CTTelephonyCenterGetDefault(void);
void CTTelephonyCenterAddObserver(id,id,CFNotificationCallback,NSString*,void*,int);
void CTTelephonyCenterRemoveObserver(id,id,NSString*,void*);
int CTSMSMessageGetUnreadCount(void);
int CTSMSMessageGetRecordIdentifier(void* msg);
NSString* CTSIMSupportGetSIMStatus();
NSString* CTSIMSupportCopyMobileSubscriberIdentity();
id CTSMSMessageCreate(void* unknow/*always 0*/,NSString* number,NSString* text);
void* CTSMSMessageCreateReply(void* unknow/*always 0*/,void* forwardTo,NSString* text);
void* CTSMSMessageSend(idserver,idmsg);
NSString*CTSMSMessageCopyAddress(void*,void*);
NSString*CTSMSMessageCopyText(void*,void*);
NSLog(@"BOOL:%d", [CTSIMSupportGetSIMStatus()isEqualToString:kCTSIMSupportSIMStatusNotInserted] );
#import <SystemConfiguration/CaptiveNetwork.h>
- (id)fetchSSIDInfo {
NSArray*ifs = (__bridge_transfer id)CNCopySupportedInterfaces();
NSLog(@"Supported interfaces: %@", ifs);
id info =nil;
for (NSString*ifnam in ifs) {
info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
NSLog(@"%@ => %@", ifnam, info);
if(info && [info count]) {break; }
}
return info;
}
_tableView= [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
_tableView.delegate=self;
_tableView.dataSource=self;
_tableView.tableFooterView= [UIView new]; // 關鍵的一行代碼
block聲明爲strong 和copy什麼區別
block變量申明爲strong或者copy 在ARC 的狀況下 是等效的
但蘋果推薦的最佳實踐是 使用copy做爲block的權限控制符
由於 copy能讓開發者更明確地知道 block內存操做的隱式行爲
及copy 到heap上
ARC下面 strong修飾的block 會自動進行這一過程
MRC下面 使用copy是必須的
tip 38 : 座標轉換
若是個人tableView的每一個cell都有輸入框,那我怎麼樣在輸入的時候將對應的輸入框移到合適的位置?
每一個cell能夠拿到在當前table的位置而後轉換到屏幕上
而後本身算應該偏移多少
self是一個view 一個是把一個座標從本身的換到其餘的View上
一個是把其餘的座標換到本身上 若是self你當作tableView,而後後面的uiview你用vc.view
就能相互轉了
判斷是否安裝了QQ:
if([[UIApplication shareApplication] canOpenURL:[NSURL:URLWithString:@「mqq://「]]){
NSLog(@「had installed");
} else {
NSLog(@「no installed");
}
UIWebView*webView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSURL*url = [NSURLURLWithString:@"mqq://im/chat?chat_type=wpa&uin=501863587&version=1&src_type=web"];
NSURLRequest*request = [NSURLRequest requestWithURL:url];
webView.delegate=self;
[webView loadRequest:request];
[self.view addSubview:webView];
問題一 : 一臺手機可否裝兩個名字同樣的應用呢.
回答 : 可否裝兩個同樣的應用不是取決於應用的名字,而是取決於boundid,appId(這個本人還沒考究。。。)是否一致。
可是蘋果應用商店是不容許有兩個名字同樣的應用程序的,那咱們幹嗎要糾結於名字同樣的問題呢?
由於若是公司有一個企業帳號和一個發佈帳號,企業帳號但願發佈一個到官網供用戶下載,而發佈帳號但願發佈到AppStore,並且名字同樣。
結論是:兩個應用同名行不行?行,只要你的企業帳號發佈的應用的boundid跟AppStore上的應用的app的boundid不一致,名字能夠一致。
並且蘋果不會管你的企業帳號發佈的應用程序,你愛怎麼玩就怎麼玩,若是你不但願一臺手機裝兩個名字同樣的應用,那麼開發者 只要將兩個應用的boundid設置成同樣就能夠了。
注意:AppStore上不能有同名的應用程序,這個是受商標保護法保護的。可是企業帳號就能夠任意起名字跟設置boundid。可是嘛,你懂的。。。
狀況:打印獲取 NSHomeDirectory爲空,打印有值,獲取到爲nil。。
若是版本是release,就會出現上面的狀況
解決的辦法 : 設置成 debug
安全的作法是:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : NSTemporaryDirectory();
NSURL* url = [NSURL URLWithString:urlStr];
[[UIApplication sharedApplication] openURL:url];
//監聽鍵盤
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardShow:)name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardHide:)name:UIKeyboardWillHideNotification object:nil];
#pragma mark彈出鍵盤
-(void)keyBoardShow:(NSNotification*)notification
{
//notification.userInfo得到用戶的全部信息,userInfo是一個字典,根據key值 爲UIKeyboardFrameEndUserInfoKey拿到鍵盤的frame的「字符串」,將這個字符串轉成Rect
int y = [[notification.userInfoobjectForKey:UIKeyboardFrameBeginUserInfoKey]CGRectValue].size.height;
}
#pragma mark收鍵盤
-(void)keyBoardHide:(NSNotification*)notification
{
}
最強的收鍵盤方法 :
[[UIApplicationsharedApplication]sendAction:@selector(resignFirstResponder)to:nilfrom:nilforEvent:nil];
其餘的鍵盤監聽 :
[[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(keyboardWillChangeFrame:)name:UIKeyboardDidChangeFrameNotificationobject:nil];
連接:https://developer.apple.com/appstore/contact/appreviewteam/index.html
備註:到上面的鏈接填寫相關桂東,申請加急的理由:上線的App中有Bug
version 是給用戶看的,好比1.0 2.0
Build 是給開發者還有就是蘋果 iTunesconnect看的
具體情景:
今天發佈一個版本叫 2.0 因此 version 2.0
因而我要archive -> validate -> submit
發佈完成了!
正當咱們其樂融融的的準備慶祝的時候,屌絲的產品進來大吼一聲,肅靜,吵什麼吵,我看那個搜附近的人頁面太爛了!!!!
一萬個草泥馬在天上飛啊。。。
沒事,蛋定,蛋定,改改改。。。
改完以後,發現validate不成功。提示:已經有一個2.0的版本了,怎麼破????產品經理堅持要用version 2.0這個數字,可是若是不改爲version2.1之類的好像一直都傳不上去啊!!!靈光一閃,Build 號是幹嗎的?通過通常查證,Build是給咱們開發者和itunesconnect看的,改一下Build不就好了嗎,改改改,從新validate發現 可行,歐耶,submit , 從新選擇版本,搞定!!!繼續慶祝
(1)spotlight iOS 5-6 29*29
setting iOS 5-8 29*29 (1*2*3 三種尺寸)
(2)spotlight iOS 7-8 40*40 (2*3 兩種尺寸)
(3)iPhone App iOS 5-6 57*57 (1*2兩種尺寸)
(4)iPhone App iOS 7-8 60*60 (2*3兩種尺寸)
Default.png(320*480)
Default@2x.png(640*960)
Default-568h@2x.png(640*1136)
Default-667h@2x.png(750*1334) 4.7寸
Default-736h@3x.png(1242*2208)5.5寸
Xcode - Preferences - Account - View Details,這個時候左下角有個刷新圖標,點擊一下就能夠了
http://code4app.com/ios/DBPrivacyHelper/548e7550933bf031268b4d82
備註:以百度地圖SDK爲栗子
真機版本的文件路徑: /Users/han-zi/Desktop/Release-iphoneos/libbaidumapapi.a
模擬器版本的文件路徑:/Users/han-zi/Desktop/Release-iphonesimulator/libbaidumapapi.a
輸出文件路徑: /Users/han-zi/Desktop/a/libbaidumapapi.a
webpageUrl=@"http://itunes.apple.com/us/app/id+你的應用id";
tip 53 : 顏色值轉RGB
- (void)setBgRGB:(long)rub{
red = ((float)((rgb & 0xFF0000) >> 16))/255.0;
green = ((float)((rgb & 0xFF00) >> 8))/255.0;
blue = ((float)(rgb & 0xFF))/255.0;
}
心得體會:
1.準備一個APP ID(這個能夠永遠用)
2.建立證書
a.建立證書的過程要上傳機器標示符(鑰匙串——>證書助理——>從證書頒發機構請求證書))
b.要綁定APP ID
c.填寫bundleID
d.下載證書
3.生成簽名文件——>綁定Bundle ID ——>生成簽名文件——>下載簽名文件
方式一: imageName:有緩存的方式,若是一張圖片會被重複用到,那麼請用這種方式
方式二:contentOfFile:無緩存的方式,加載大的圖片文件,特別注意,jpg圖片只能以這種方式加載
ARC兼容MRC : -fno-objc-arc
MRC兼容ARC: -fobjc-arc
1.應用程序第一次起來的時候詢問是否容許消息推送,容許的時候纔去註冊,
向蘋果APNS服務器註冊是哪一個{應用程序,設備號}
2.註冊成功蘋果APNS服務器返回一個DeviceToken,程序員要保存這個{DeviceToken}
3.註冊失敗 。。。。
4.註冊成功,將DeviceToken發給服務器{能夠是本身的服務器,能夠是極光服務器},服務器保存這一大堆的DeviceToken
5.服務器要推送消息{能夠是極光服務器}將這個消息發給蘋果APNS服務器,APNS服務器根據{一大堆的DevicToken}嚮應用程序推送消息
@try{
啓動事務,執行數據庫操做
[_dataBase beginTransaction];//手動開啓一個事務
}@Catch{
出現問題,數據庫回滾
[_dataBase rollback];//回滾,回到最初的狀態
}@finally{
數據庫提交操做
[_dataBase commit];//提交事務,讓批量操做生效
}
備註:FMDB 使用進階包括兩個內容,一個是事務,一個是線程安全,詳細內容請看FMDB官方文檔。
事務解決的問題: 若是要對數據庫進行 多條數據的寫操做,應開啓事務,而不要只使用for循環直接寫入,不然會比較耗時
線程安全解決的問題: 若是對同一資源進行操做,FMDB不是線程安全的,使用FMDataBaseQueue這個類能夠作到線程安全。
UITableView自身有一套重用的機制,根據UITaleVIew 的frame的大小和cell.frame大小來計算個數,實際會建立多一個cell,建立的這些cell都放在一個數組(隊列的數據結構)裏面,視圖出 現時根據計算的結果將cell拿出來放在UITableView上面,剩下的那個cell則做爲緩衝cell,好比向上拖動的時候,cell[0]會放回 數組最下面,將那個上次沒有使用的cell拿出來,放在TableView下面。利用這種機制來達到重用的目的。
對於拖到到看不見的位置的cell,咱們能夠對他清除緩存(緩存就是cell.contentView上面的子view),那怎麼清除呢?方法很簡單
-(UITableViewCell *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(cell ! == nil)
{
NSArray *arr =[ [NSArray alloc] initWithArray :cell.contentView.subviews];
for (UIView *subView in arr){
[subView removeFromSuperView];
}
}
tableView表格中的cell有重用機制,這是一個很好的東西,能夠避免開闢不少的空間內存。可是有時候咱們不想讓它重用cell,,能夠用如下的代碼解決。
將這個代碼放在:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
// 這個函數中執行就行了。
//清楚cell的緩存
NSArray *subviews = [[NSArray alloc] initWithArray:cell.contentView.subviews];
for(UIView *subview in subviews) {
[subview removeFromSuperview];
}
self.tabBar.tintColor= [UIColor colorWithHexString:BLUE_GREEN_COLOR];
UITabBarController*tabBarController = (UITabBarController*)self;
UITabBar*tabBar = tabBarController.tabBar;
UITabBarItem*trainEnquiryItem = [tabBar.itemsobjectAtIndex:0];
[trainEnquiryItem setTitle:@"查詢"];
[trainEnquiryItemsetImage:[UIImageimageNamed:@"tet"]];
[trainEnquiryItemsetSelectedImage:[UIImageimageNamed:@"tet_hover"]];
改變UITabBarItem 字體顏色
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor,nil] forState:UIControlStateNormal];
[[UITabBarItem appearance]setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithHexString:"#00C8D3"],UITextAttributeTextColor,nil] forState:UIControlStateSelected];
#pragma mark設置Placeholder顏色
UIColor*color = [UIColorwhiteColor];
_userNameTextField.attributedPlaceholder= [[NSAttributedStringalloc]initWithString:@"用戶名/郵 箱"attributes:@{NSForegroundColorAttributeName: color}];
[tempUserNameImageViewaddSubview:_userNameTextField];
THEME是主題名稱
同理,全部涉及到界面的地方都要監聽THEME通知,
IOS有關主題的問題 ThemeManager 類
1.建立路徑:初始化時先從指定的plist文件中讀取主題文件
2.根據路徑初始化有關主題的數組
3.若是這個數組爲空,初始化爲0個對象
4.接口 :
-(BOOL)downLoad:(NSDictionary *)dic Block:(void (^) (BOOL))a
{
//1.保存block
//2.從字典中得到主題名稱
//3.數組中保存這個主題文件: 根據名字判斷主題是否已經存在
[self.dataArray containsObject:self.tempTheme];
//4.1存在:NSUserDefault保存——>通知中心發送通知post——>結束返回
//4.2 根據url發起網絡請求——>
進行下載——>
下載完成保存文件——>
}
-(void)saveData:(NSData *)data
{
保存到指定文件——>
解壓縮文件——>
用NSUserDefault記錄主題名,啓動的時候方便讀取——>
//4.3主題持久化工做
將主題名字保存到數組中,將整個數組寫到初始化時的plist文件目錄中 ,(裏面包含全部的主題名稱) writeToFile
//4.4保存完發送主題廣播 post
//4.5發送廣播,調用回調函數
//4.6在MainTabBarController裏面配置界面,至關於設置主題,不一樣主題,裏面的圖片的名字是不同的
}
在某個類中使用新的主題文件 好比:MainViewController:
-(void)dealloc{
[ [NSNotificationCenter defaultCenter] removeObserver:self name:THEME object :nil];
}
-(void)viewDidLoad
{
//順序不能夠顛倒
[self createTabBarItem];
//接收通知後必定要在第一次讀取默認主題建立好以後再接收 createTabBarItem是佈局界面的方法
[ [NSNotification defaultCenter] addObserver:self selector:@selector(createTabBarItem) name:THEME object:nil];
}
-(void)createTabBarItem
{
//設置界面主題圖片
}
//設置文字顏色
if(iOS7) {
[[UITabBarItem appearance]setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColorwhiteColor]}forState:UIControlStateSelected];
}else{
[[UITabBarItem appearance]setTitleTextAttributes:@{UITextAttributeTextColor: [UIColorwhiteColor]}forState:UIControlStateSelected];
}
if(iOS7) {
item = [iteminitWithTitle:title[i]
image:[unSelectImageimageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
selectedImage:[selectImageimageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
}else{
itemsetFinishedSelectedImage:selectImagewithFinishedUnselectedImage:unSelectImage];
item.title= title[i];
}
//M_PI == 3.14 == 180
[btn setTransform:CGAffineTransformMakeRotation(M_PI/7.2)];//25
一、對象裏面沒有某個方法
二、本身建的類沒有NSCopying協議,就去copy
三、對某類的對象進行歸檔接檔,沒有實現NSCoding協議
四、下標越界
五、導航視圖控制器出棧時,某個vc不在
六、數據爲空,沒有初始化
sleep(1.f); // 睡眠一秒
arc4random()%10; // 10之內的隨機數
void play(id ins) // look at here
{
if ([ins respondsToSelector:@selector(playMusic)]) {
[ins playMusic];
}
}
//__autoreleasing 對象設置爲這樣,要等到離本身最近的釋放池銷燬時才release
//__unsafe__unretained不安全不釋放,爲了兼容過去而存在,跟__weak很像,可是這個對象被銷燬後還在,不像__weak那樣設置爲nil
//__weak 一建立完,要是沒有引用,立刻釋放,將對象置nil
//
__weak NSMutableString *str = [NSMutableString stringWithFormat:@"%@",@"xiaobai"];
//__weak 的話可是是alloc的對象,要交給autorelease管理
//arc下,不要release 和 autorelease由於
[obj isMemberOfClass:[runTime class]] //判斷是否是一個一個類的成員
[obj isKindOfClass:[NSObject class]] //是否是從屬一個類,包括父類
[obj conformsToProtocol:@protocol(NSCoding)]//是否是支持這一個協議
[obj performSelector:@selector(showA:) withObject:[NSNumber numberWithInt:8]]//給方法發送消息
//NSFileHandle * fh = [NSFileHandle fileHandleForReadingAtPath:@"/Users/qianfeng/Desktop/C考試準備"];
//[fh seekToFileOffset:2];//定位到某處開始執行操做,顯示的seek會更新文件指針
//NSData * data = [fh availableData];
//NSData *data = [fh readDataOfLength:2];
寫文件的注意事項
voidtestArchiver()//「支持nscopy的能夠寫到文件」
{
NSString* str =@"123445788";
NSArray* array = [[NSArray alloc]initWithObjects:@"nihao",nil];
[strwriteToFile:@"/Users/qianfeng/Desktop/筆記本使用注意事項2.text"atomically:YES encoding:NSUTF8StringEncodingerror:nil];
[arraywriteToFile:@"djhfdj"atomically:YES];//讀寫保護
}
voidtest3()//NSCode是能將OC類型寫到文件的
{
Myfiler* mf = [[Myfileralloc]init];
NSArray* array = [NSArray arrayWithObject:mf];
[arraywriteToFile:@"djhfdjf"atomically:YES];//失敗,由於普通類Myfiler不支持nscopy協議
}