有遇到Apple賬號(hào)申請(qǐng)問(wèn)題,App上傳Appstore問(wèn)題,iTunes Connect相關(guān)問(wèn)題,都可以根據(jù)您所在地區(qū)撥打相應(yīng)的電話進(jìn)行咨詢,我以前打過(guò)【China English, 普通話 Mon-Fri, 09:00-17:00 CST 4006 701 855】:點(diǎn)擊查看電話列表
1、生成隨機(jī)數(shù)
int x = arc4random() % 9;生成以為隨機(jī)數(shù)
生成6位隨機(jī)數(shù)
NSString *strRandom = @"";
for(int i=0; i<7; i++)
{
strRandom = [strRandom stringByAppendingFormat:@"%i",(arc4random() % 9)];
}
NSLog(@"隨機(jī)數(shù): %@", strRandom);
2、判斷App是否第一次啟動(dòng)
if(![[NSUserDefaults standardUserDefaults] boolForKey:@"firstStart"]){
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstStart"];
NSLog(@"第一次啟動(dòng)");
}else{
NSLog(@"不是第一次啟動(dòng)");
}
3、UIView中的initWithFrame 和 initWithCoder
當(dāng)我們所寫(xiě)的程序里沒(méi)用用Nib文件(XIB)時(shí),用代碼控制視圖內(nèi)容,需要調(diào)用initWithFrame去初始化
- (id)initWithFrame:(CGRect)frame
{
if (self =[super initWithFrame:frame]) {
// 初始化代碼
}
return self;
}
用于視圖加載nib文件,從nib中加載對(duì)象實(shí)例時(shí),使用 initWithCoder初始化這些實(shí)例對(duì)象
- (id)initWithCoder:(NSCoder*)coder
{
if (self =[super initWithcoder:coder]) {
// 初始化代碼
}
return self;
}
4、一個(gè)Lable有多種顏色類似這樣:

NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"恭喜130****8565 于04月02日獲得iPhone6s"];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor darkGrayColor] range:NSMakeRange(0,1)];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(2,12)];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(15,5)];
UILabel *attrLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 64, 320 - 40, 90)];
attrLabel.attributedText = str;
attrLabel.numberOfLines = 0;
[self.view addSubview:attrLabel];
5、獲取當(dāng)前時(shí)間的年月日時(shí)分秒
6、
調(diào)用代碼使APP進(jìn)入后臺(tái)
帶中文的URL處理
取WebView高度
View設(shè)置圖片
去TableView分割線
調(diào)cell分割線位置
七、Label注意事項(xiàng)
搜索條Cancel改標(biāo)題
TableView收鍵盤(pán)
NSTimer
控制器沒(méi)大小
十六進(jìn)制取顏色
獲取今天是星期幾
UIView的部分圓角問(wèn)題
滑動(dòng)時(shí)隱藏navigationBar
iOS畫(huà)虛線
自動(dòng)布局多行UILabel問(wèn)題
禁止運(yùn)行時(shí)自動(dòng)鎖屏
KVC相關(guān)
用MBProgressHud問(wèn)題
強(qiáng)制App直接退出
Label行間距
pod更新慢的問(wèn)題
MRC和ARC混編設(shè)置方式
cell對(duì)勾顏色修改
同時(shí)按兩個(gè)按鈕問(wèn)題
修改占位符顏色和大小
禁止復(fù)制粘貼
進(jìn)入App在AppStore頁(yè)面
隱藏系統(tǒng)tabbar
取消系統(tǒng)的返回手勢(shì)
改WebView字體/顏色
7、 運(yùn)行錯(cuò)誤信息No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=armv7
運(yùn)行報(bào)錯(cuò)出現(xiàn)的原因:armv7s是應(yīng)用在iPhone 5 A6 的架構(gòu)上的解決的方式:
1、在Project target里“Architectures”設(shè)置為“Standard (armv7,armv7s)”
2、修改在Project target里“Build Settings”的“Valid Architectures”添加“i386”和“armv7”(Xcode4.6 以上版本不再支持armv6,請(qǐng)去掉)
3、設(shè)置”Build Active Architecture Only”為“NO”。這樣你build你的項(xiàng)目的時(shí)候就能在iphoe5和iphoe4s里執(zhí)行。armv6, armv7, armv7s的區(qū)別
8、Mac 刷新DNS命令:
10.10.4 or later:
sudo killall -HUP mDNSResponder
10.10 ~ 10.10.3:
sudo discoveryutil mdnsflushcache
10.7 ~ 10.9.5:
sudo killall -HUP mDNSResponder
10.6 ~ 10.6.8:
sudo dscacheutil -flushcache
9、NSData和NSDictionary轉(zhuǎn)換
獲得的json先轉(zhuǎn)換成字符串
NSString *receiveStr = [[NSString alloc]initWithData:receiveData encoding:NSUTF8StringEncoding];
字符串再生成
NSDataNSData * data = [receiveStr dataUsingEncoding:NSUTF8StringEncoding];
再解析
NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
就OK了
10、
iOS10相關(guān)問(wèn)題記錄:
iOS10相冊(cè)相機(jī)閃退bug
iOS 10 因蘋(píng)果健康導(dǎo)致閃退 crash
麥克風(fēng)、多媒體、地圖、通訊錄
ios10相機(jī)等崩潰
iOS10 配置須知
iOS開(kāi)發(fā) 適配iOS10以及Xcode8
iOS 10 的適配問(wèn)題
iOS對(duì)用戶的安全和隱私的增強(qiáng),在申請(qǐng)很多私有權(quán)限的時(shí)候都需要添加描述,但是,在使用Xcode 8之前的Xcode還是使用系統(tǒng)的權(quán)限通知框.
要想解決這個(gè)問(wèn)題,只需要在info.plist添加NSContactsUsageDescription的key, value自己隨意填寫(xiě)就可以,這里列舉出對(duì)應(yīng)的key(Source Code模式下):
iOS11以前:
NSPhotoLibraryUsageDescription:訪問(wèn)相冊(cè)和存儲(chǔ)照片到相冊(cè)(讀寫(xiě)),會(huì)出現(xiàn)用戶授權(quán)。
iOS11之后:
NSPhotoLibraryUsageDescription:無(wú)需添加。默認(rèn)開(kāi)啟訪問(wèn)相冊(cè)權(quán)限(讀),無(wú)需用戶授權(quán)。
NSPhotoLibraryAddUsageDescription: 添加內(nèi)容到相冊(cè)(寫(xiě)),會(huì)出現(xiàn)用戶授權(quán)。
<!-- 相冊(cè) -->
<key>NSPhotoLibraryUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)相冊(cè)</string>
<!-- 相機(jī) -->
<key>NSCameraUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)相機(jī)</string>
<!-- 麥克風(fēng) -->
<key>NSMicrophoneUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)麥克風(fēng)</string>
<!-- 位置 -->
<key>NSLocationUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)位置</string>
<!-- 在使用期間訪問(wèn)位置 -->
<key>NSLocationWhenInUseUsageDescription</key>
<string>App需要您的同意,才能在使用期間訪問(wèn)位置</string>
<!-- 始終訪問(wèn)位置 -->
<key>NSLocationAlwaysUsageDescription</key>
<string>App需要您的同意,才能始終訪問(wèn)位置</string>
<!-- 日歷 -->
<key>NSCalendarsUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)日歷</string>
<!-- 提醒事項(xiàng) -->
<key>NSRemindersUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)提醒事項(xiàng)</string>
<!-- 運(yùn)動(dòng)與健身 -->
<key>NSMotionUsageDescription</key> <string>App需要您的同意,才能訪問(wèn)運(yùn)動(dòng)與健身</string>
<!-- 健康更新 -->
<key>NSHealthUpdateUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)健康更新 </string>
<!-- 健康分享 -->
<key>NSHealthShareUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)健康分享</string>
<!-- 藍(lán)牙 -->
<key>NSBluetoothPeripheralUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)藍(lán)牙</string>
<!-- 媒體資料庫(kù) -->
<key>NSAppleMusicUsageDescription</key>
<string>App需要您的同意,才能訪問(wèn)媒體資料庫(kù)</string>
11、tableView在編輯狀態(tài)下的批量操作(多選)
注意:
** cell的selectionStyle不要設(shè)置為UITableViewSelectionStyleNone**
12、設(shè)置圓角:layer.cornerRadius

13、 解決iOS The document “(null)” requires Xcode 8.0 or later. 不能編譯的問(wèn)題:
用文本編輯器打開(kāi)對(duì)應(yīng)的 xib 文件,刪除其中類似這樣的一句話 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
14、 iOS中判斷是從哪個(gè)控制器push進(jìn)來(lái)的,返回指定控制器:
1、
push將控制器壓到棧中,棧是先進(jìn)后出;pop是出棧:即將控制器從棧中取出。
NSArray*arrController =self.navigationController.viewControllers;
NSInteger VcCount = arrController.count;
//最后一個(gè)vc是自己,(-2)是倒數(shù)第二個(gè)是上一個(gè)控制器。
UIViewController *lastVC = arrController[VcCount - 3];
// 返回到倒數(shù)第三個(gè)控制器
if ([lastVC isKindOfClass:[XZViewController class]]) {
[self.navigationController popToViewController:lastVC animated:YES];
}
2、
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:0] animated:YES];
3、
返回到指定的控制器:遍歷一遍子控制器,判斷一下哪個(gè)是要返回的控制器,進(jìn)行返回
for (UIViewController *controller in self.navigationController.viewControllers) {
if ([controller isKindOfClass:[XZViewController class]]) {
[self.navigationController popToViewController:controller animated:YES];
}
}
15、關(guān)于iOS去除數(shù)組中重復(fù)數(shù)據(jù)的幾種方法:連接
16、iOS9 適配(https適配信息):
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
17、Xcode 遇到這個(gè)問(wèn)題**Installation Failed Invalid argument **

Quit Xcode
Clean out ~/Library/Developer/Xcode/DerivedData manually
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
iOS Simulator > Reset Content and Settings
導(dǎo)入系統(tǒng)頭文件
#import <SystemConfiguration/CaptiveNetwork.h>
實(shí)現(xiàn)代碼
NSString *ssid = @"Not Found";
NSString *macIp = @"Not Found";
CFArrayRef myArray = CNCopySupportedInterfaces();
if (myArray != nil) {
CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
if (myDict != nil) {
NSDictionary *dict = (NSDictionary*)CFBridgingRelease(myDict);
ssid = [dict valueForKey:@"SSID"];
macIp = [dict valueForKey:@"BSSID"];
}
}
UIAlertView *av = [[UIAlertView alloc] initWithTitle:ssid
message:macIp
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:@"OK", nil];
[av show];
19、iOS 獲取當(dāng)前設(shè)備型號(hào)iPhone7/iPhone7P
20、解決10.12安全與隱私?jīng)]有允許任何來(lái)源的選項(xiàng)
在終端里輸入:sudo spctl --master-disable 然后回車(chē)即可在安全選項(xiàng)中看到重新出現(xiàn)的允許任何來(lái)源選項(xiàng)!
21、真機(jī)調(diào)試:Development cannot be enabled while your device is locked.
解決方法:打開(kāi)手機(jī)設(shè)置->通用->還原->還原位置與隱私;
拔掉數(shù)據(jù)線,重啟xocde 8開(kāi)啟項(xiàng)目, 重新插上數(shù)據(jù)線,此時(shí)手機(jī)上會(huì)顯示mac與手機(jī)設(shè)備的連接訪問(wèn)權(quán)限,選擇“信任”,
22、iOS不支持64系統(tǒng)報(bào)錯(cuò)的解決方法:
錯(cuò)誤No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=armv7, VA

解決方法:
運(yùn)行報(bào)錯(cuò)出現(xiàn)的原因:armv7s是應(yīng)用在iPhone 5 A6 的架構(gòu)上的解決的方式:
1,在Project target里“Architectures”設(shè)置為“Standard (armv7,armv7s)”
2,修改在Project target里“Build Settings”的“Valid Architectures”添加“i386”和“armv7”(Xcode4.6 以上版本不再支持armv6,請(qǐng)去掉)
3,設(shè)置”Build Active Architecture Only”為“NO”。這樣你build你的項(xiàng)目的時(shí)候就能在iphoe5和iphoe4s里執(zhí)行。armv6, armv7, armv7s的區(qū)別
No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386)
23 如果你的項(xiàng)目莫名奇妙的出現(xiàn)
: Linker command failed with exit code 1 (use -v to see invocation)

解決:好吧我不知道為啥Xcode8之后就沒(méi)法看詳情了。但是可能是BitCode搞得鬼
自記:用callkit的時(shí)候,記入帶區(qū)號(hào)的號(hào)碼時(shí)格式如010 ->10不要帶0
24 Signing for "" requires a development team. Select a developm
25 真機(jī)調(diào)試出現(xiàn)這個(gè)錯(cuò)誤
This application's application-identifier entitlement does not match that of the installed application. These values must match for an upgrade to be allowed
解決方法:
1、Xcode-Window->Devices
2、選中你的設(shè)備,在右邊的installed Apps中刪除這個(gè)App
3、重新編繹即可
26 addSubview和insertSubview的理解(自己記錄便于查詢)
addSubview是一層一層往上加,新加的只能放到父視圖的最上層,
insertSubView可以控制它添加到父視圖的哪一層
A addSubview B 是將B直接覆蓋在A的最上層
A insertSubView B AtIndex:2 是將B插入到A的子視圖index為2的位置(最底下是0)
A insertSubView B aboveSubview:C 是將B插入A并且在A已有的子視圖C的上面
A insertSubView B belowSubview:C 是將B插入A并且在A已有的子視圖C的下面
27 如果你發(fā)現(xiàn)自己的iPhone模擬器慢慢吞吞的,做什么都很慢,那你應(yīng)該打開(kāi)了這個(gè):

建議關(guān)閉后試試!
聲明:這些知識(shí)也都是我用到過(guò)然后從網(wǎng)絡(luò)上找的別人的,主要是方便自己查閱。順便分享出來(lái)希望可以幫到正好需要的朋友!