iOS開發(fā)過程中遇到的一些問題 記錄一下!

經(jīng)常在開發(fā)過程中遇到一些奇葩的問題
這邊做一個(gè)總結(jié),記錄一下開發(fā)過程中踩過的坑


1.保證列表起點(diǎn)的Y坐標(biāo)是在 nav 下邊

if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) { // 這行代碼是 保證列表起點(diǎn)的Y坐標(biāo)是在 nav 下邊 () self.edgesForExtendedLayout = UIRectEdgeNone; }


2.app內(nèi)跳轉(zhuǎn)系統(tǒng)設(shè)置app相關(guān)內(nèi)容
os系統(tǒng)中各種設(shè)置項(xiàng)的url鏈接

在代碼中調(diào)用如下代碼:

NSURL*url=[NSURL URLWithString:@"prefs:root=WIFI"];

[[UIApplication sharedApplication] openURL:url];

即可跳轉(zhuǎn)到設(shè)置頁面的對應(yīng)項(xiàng)。

[font=]

About — prefs:root=General&path=About

Accessibility — prefs:root=General&path=ACCESSIBILITY

Airplane Mode On — prefs:root=AIRPLANE_MODE

Auto-Lock — prefs:root=General&path=AUTOLOCK

Brightness — prefs:root=Brightness

Bluetooth — prefs:root=General&path=Bluetooth

Date & Time — prefs:root=General&path=DATE_AND_TIME

FaceTime — prefs:root=FACETIME

General — prefs:root=General

Keyboard — prefs:root=General&path=Keyboard

iCloud — prefs:root=CASTLE

iCloud Storage & Backup — prefs:root=CASTLE&path=STORAGE_AND_BACKUP

International — prefs:root=General&path=INTERNATIONAL

Location Services — prefs:root=LOCATION_SERVICES

Music — prefs:root=MUSIC

Music Equalizer — prefs:root=MUSIC&path=EQ

Music Volume Limit — prefs:root=MUSIC&path=VolumeLimit

Network — prefs:root=General&path=Network

Nike + iPod — prefs:root=NIKE_PLUS_IPOD

Notes — prefs:root=NOTES

Notification — prefs:root=NOTIFICATIONS_ID

Phone — prefs:root=Phone

Photos — prefs:root=Photos

Profile — prefs:root=General&path=ManagedConfigurationList

Reset — prefs:root=General&path=Reset

Safari — prefs:root=Safari

Siri — prefs:root=General&path=Assistant

Sounds — prefs:root=Sounds

Software Update — prefs:root=General&path=SOFTWARE_UPDATE_LINK

Store — prefs:root=STORE

Twitter — prefs:root=TWITTER

Usage — prefs:root=General&path=USAGE

VPN — prefs:root=General&path=Network/VPN

Wallpaper — prefs:root=Wallpaper

Wi-Fi — prefs:root=WIFI

prefs:root=INTERNET_TETHERING


3.iOS_生成pem推送證書,用于自己搭建推送服務(wù)器的時(shí)候,跟后端匹配證書問題
具體步驟如下:

首先,需要一個(gè)pem的證書,該證書需要與開發(fā)時(shí)簽名用的一致。 具體生成pem證書方法如下:

1. 登錄到 iPhone Developer Connection Portal(http://developer.apple.com/iphone/manage/overview/index.action)并點(diǎn)擊 App IDs

2. 創(chuàng)建一個(gè)不使用通配符的 App ID 。通配符 ID 不能用于推送通知服務(wù)。例如,??com.itotem.iphone

3. 點(diǎn)擊App ID旁的“Configure”,然后按下按鈕生產(chǎn) 推送通知許可證。根據(jù)“向?qū)А?的步驟生成一個(gè)簽名并上傳,最后下載生成的許可證。

4. 通過雙擊.cer文件將你的 aps_developer_identity.cer 引入Keychain中。

5. 在Mac上啟動 Keychain助手,然后在login keychain中選擇 Certificates分類。你將看到一個(gè)可擴(kuò)展選項(xiàng)“Apple Development Push Services”

6. 擴(kuò)展此選項(xiàng)然后右擊“Apple Development Push Services” > Export “Apple Development Push Services ID123”。保存為 apns-dev-cert.p12文件

7. 擴(kuò)展“Apple Development Push Services” 對“Private Key”做同樣操作,保存為 apns-dev-key.p12 文件。

8. 需要通過終端命令將這些文件轉(zhuǎn)換為PEM格式:openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12

openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12

9. 如果你想要移除密碼,要么在導(dǎo)出/轉(zhuǎn)換時(shí)不要設(shè)定或者執(zhí)行:

openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem

10. 最后,你需要將鍵和許可文件合成為apns-dev.pem文件,此文件在連接到APNS時(shí)需要使用:

cat apns-dev-cert.pem apns-dev-key-noenc.pem > apns-dev.pem


4.篩選某個(gè)viewcontroller

for(UIViewController*tempVC in [self.navigationController viewControllers])

{

if([tempVC isKindOfClass:[MakeSureAddressViewController class]])

{

[tempNavBarItems removeFromParentViewController];

}

}


5.判斷一個(gè)坐標(biāo)點(diǎn)是否在一個(gè)無規(guī)則的多邊形內(nèi)

//????在范圍內(nèi)返回1,不在返回0

-(int)mutableBoundConrtolAction:(NSMutableArray?*)arrSome:(CLLocationCoordinate2D?)myCoordinate4{

intn=arrSome.count;

floatvertx[n];

floatverty[n];

for(inti=0;?i

//MyPoint類存儲的是經(jīng)度和緯度

vertx[i]=((MyPoint?*)(arrSome[i])).x;

verty[i]=((MyPoint?*)(arrSome[i])).y;

}

if(arrSome.count==0)?{

return1;

}

BOOLi=pnpoly(arrSome.count,?vertx,?verty,?myCoordinate4.latitude,?myCoordinate4.longitude);

if(i)?{

return1;

}else{

return0;

}

return1;

}

//多邊形由邊界的坐標(biāo)點(diǎn)所構(gòu)成的數(shù)組組成,參數(shù)格式?該數(shù)組的count,??多邊形邊界點(diǎn)x坐標(biāo)?的組成的數(shù)組,多邊形邊界點(diǎn)y坐標(biāo)?的組成的數(shù)組,需要判斷的點(diǎn)的x坐標(biāo),需要判斷的點(diǎn)的y坐標(biāo)

BOOLpnpoly?(intnvert,float*vertx,float*verty,floattestx,floattesty)?{

inti,?j;

BOOLc=NO;

for(i?=?0,?j?=?nvert-1;?i?<?nvert;?j?=?i++)?{

if(?(?(verty[i]>testy)?!=?(verty[j]>testy)?)?&&

(testx?<?(vertx[j]-vertx[i])?*?(testy-verty[i])?/?(verty[j]-verty[i])?+?vertx[i])?)

c?=?!c;

}

returnc;

}


6.XCode 開發(fā)去除 UserInterfaceState.xcuserstate 文件為版本控制帶來的困擾

原理和操作步驟見如下轉(zhuǎn)載的兩篇文章,

我所使用的 svn 客戶端軟件是 Mac 下面的 Versions.app v1.06

這個(gè)版本包含一個(gè)多人開發(fā)的bug

bug 的解決方案見我之前轉(zhuǎn)載的兩篇文章~

另外就是如本文轉(zhuǎn)載的第一篇文章,我也深受 UserInterfaceState.xcuserstate 文件頻繁更新帶來的困擾,

要免除該困擾,可在 Versions 的配置文件~/.subversion/config 中忽略對 xcuserstate 類型文件的版本控制。

另外,Versions 的配置文件是處于隱藏目錄的,可在 Finder 中通過 cmd + shift + g 直接跳到隱藏目錄~

************************ 分割線 ***************************

文章標(biāo)題:

擺脫 UserInterfaceState.xcuserstate給Xcode 版本控制(git)帶來的困擾

轉(zhuǎn)載自:http://alexrezit.42qu.com/10280223

今天在Xcode中Commit的時(shí)候UserInterfaceState.xcuserstate這個(gè)文件幾秒鐘更新一次, 攪得人不得安寧, 用.gitignore無效. 于是, 在終端中輸入:

$ git rm --cached iLedger.xcodeproj/project.xcworkspace/xcuserdata/Alex.xcuserdatad/UserInterfaceState.xcuserstate

$ git commit -m "Removed the stupid strange file that shouldn't be tracked"

$ git push

搞定!

************************ 分割線 ***************************

文章標(biāo)題:

XCode SVN

轉(zhuǎn)載自:http://renxiangzyq.iteye.com/blog/850762

Create the project in XCODE.

Setup subversion in XCODE and select the subversion repository for this project.

Use Xcode SCM > Repository and click on the IMPORT icon. This will move the local copy to the subversion repository.

Now delete your local copy (or move it to another location just in case).

Finally CHECKOUT the project from subversion (this will create the subversion .svn folders, …).

Reselect the subversion repository for this project.

Commit the entire project.

第一步,配置Subversion

Xcode中SVN使用時(shí)需要配置Subversion。Leopard中自帶了SVN,但Xcode的項(xiàng)目文件中,并不是所有文件都適于加入SVN中進(jìn) 行管理,比如編譯后的文件和編譯過程中產(chǎn)生的文件,這些文件不屬于源代碼,應(yīng)該告訴svn忽略掉,方法:編輯~/.subversion/config文 件

1.找到global-ignores一行,去掉注釋,編輯成

global-ignores=build*~.nib*.so*.pbxuser*.mode*.perspective*

Xcode項(xiàng)目文件中有些文件是文本文件,需要告訴SVN,因?yàn)镾VN能更好地管理文本文件(誰用誰知道)

2.找到enable-auto-props=yes把注釋去掉,在[auto-props]Section聲明以下文本文件

*.mode*=svn:mime-type=text/X-xcode

*.pbxuser=svn:mime-type=text/X-xcode

*.perspective*=svn:mime-type=text/X-xcode

*.pbxproj=svn:mime-type=text/X-xcode



7.對于 輸入框?yàn)榭占拜斎雲(yún)?shù)只有空格的判斷 ios

-(Bool) isEmpty:(NSString*) str {

if(!str) {

returntrue;

}else{

//A character set containing only the whitespace characters space (U+0020) and tab (U+0009) and the newline and nextline characters (U+000A–U+000D, U+0085).

NSCharacterSet*set =[NSCharacterSetwhitespaceAndNewlineCharacterSet];

//Returns a new string made by removing from both ends of the receiver characters contained in a given character set.

NSString*trimedString = [strstringByTrimmingCharactersInSet:set];

if([trimedStringlength] ==0) {

returntrue;

}else{

returnfalse;

}

}

}


8.ios-->截圖、生成指定大小圖片以及壓縮

1、截圖

UIImage*snapshot;

CGImageRefcgScreen=UIGetScreenImage();

if(cgScreen){

snapshot=[UIImageimageWithCGImage:cgScreen];

CGImageRelease(cgScreen);

}

CGRectrect=CGRectMake(0,125,640,750);//創(chuàng)建要剪切的矩形框這里你可以自己修改

UIImage*res=[UIImageimageWithCGImage:CGImageCreateWithImageInRect([snapshotCGImage],rect)]

//res就是截圖后的UIImage

2、生成指定大小圖片

+ (UIImage *)compressImage:(UIImage *)imgSrc

{

CGSize size = {320, 480};

UIGraphicsBeginImageContext(size);

CGRect rect = {{0,0}, size};

[imgSrc drawInRect:rect];

UIImage *compressedImg = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return compressedImg;

}

3、壓縮

UIImage *img = [CImageUtil compressImage:[info objectForKey:@"UIImagePickerControllerOriginalImage"]];

NSData *imageData = [[NSData alloc] initWithData:UIImageJPEGRepresentation(img, 0.1)];

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 228,606評論 6 533
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 98,582評論 3 418
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 176,540評論 0 376
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,028評論 1 314
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 71,801評論 6 410
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 55,223評論 1 324
  • 那天,我揣著相機(jī)與錄音,去河邊找鬼。 笑死,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,294評論 3 442
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 42,442評論 0 289
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 48,976評論 1 335
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 40,800評論 3 354
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 42,996評論 1 369
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,543評論 5 360
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 44,233評論 3 347
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,662評論 0 26
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,926評論 1 286
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 51,702評論 3 392
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 47,991評論 2 374

推薦閱讀更多精彩內(nèi)容