iOS FAQソリューション(長期更新)
4499 ワード
整理時間:2017年05月02日12:06:17
1.XCode 8.1のbundle format unrecognized,invalid,or unsuitableの問題を解決する
注意一般的にCocoaPodsで使用される問題
ソリューション:まずPodsの下であなたの目標の工事 を選択します Generalタブ が表示されます. Generalタブの下にあるIdentity Choose infoを選択する.plistは次に をインポートするは、続いて、Product Clean を実行する.
2.tableView分割線を解決し、一番左の画面に触れない
注意追加の処理をしないと、分割線はデフォルトで左端に触れません.これはアップル内蔵apiが決定します.
ソリューション:次の方法で実現
3.縦横画面の切り替えを解決し、幅と高さの数値が正しくない
ソリューション:
4.リソースDocumentディレクトリの下に置かれているiTunesに同期される問題の解決
5.Undefined symbols for architecture armv 7:"_objc_readClassPair",referenced from:_ARCLite__load() in libarclite_iphoneos.a(arclite.o)
6.CocoaPodsのサードパーティ製ライブラリへのインポートを解決し、ヘッダファイルが見つからないことを示す
7.iOS 8以上ホワイトステータスバー
ステータスバーのフォントが黒:UIstatusBarStyleDefaultステータスバーのフォントが白:UIstatusBarStyleLightContent
8.iOS 9&iOS 10 HTTPが正常に使用できない解決方法
9.強制終了app
1.XCode 8.1のbundle format unrecognized,invalid,or unsuitableの問題を解決する
注意一般的にCocoaPodsで使用される問題
ソリューション:
2.tableView分割線を解決し、一番左の画面に触れない
注意追加の処理をしないと、分割線はデフォルトで左端に触れません.これはアップル内蔵apiが決定します.
ソリューション:次の方法で実現
// _cofTableView, tableView
#pragma mark - tableView seprator line cant touch left
- (void)viewDidLayoutSubviews
{
if ([_cofTableView respondsToSelector:@selector(setSeparatorInset:)]) {
[_cofTableView setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 0)];
}
if ([_cofTableView respondsToSelector:@selector(setLayoutMargins:)]) {
[_cofTableView setLayoutMargins:UIEdgeInsetsMake(0, 0, 0, 0)];
}
}
#pragma mark - tableView delegate
- (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];
}
}
3.縦横画面の切り替えを解決し、幅と高さの数値が正しくない
ソリューション:
#pragma mark - orientation private method
//
- (void)addObserver
{
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange) name:UIDeviceOrientationDidChangeNotification object:nil];
}
//
- (void)deviceOrientationDidChange
{
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
if(orientation == UIDeviceOrientationPortrait || orientation == UIDeviceOrientationPortraitUpsideDown) {
_cofTableView.frame = CGRectMake(0, 0, kScreenW, kScreenH);
} else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight ) {
_cofTableView.frame = CGRectMake(0, 0, kScreenW, kScreenH);
}
}
//
- (BOOL)shouldAutorotate
{
return NO;
}
4.リソースDocumentディレクトリの下に置かれているiTunesに同期される問題の解決
+ (BOOL)addSkipBackupAttributeToItemAtPath:(NSString*)filePathString
{
//
NSURL *URL= [NSURL fileURLWithPath: filePathString];
assert([[NSFileManager defaultManager] fileExistsAtPath:[URL path]]);
NSError *error = nil;
BOOL success = [URL setResourceValue:[NSNumber numberWithBool:YES] forKey:NSURLIsExcludedFromBackupKey error:&error];
if(!success) {
NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
}
return success;
}
5.Undefined symbols for architecture armv 7:"_objc_readClassPair",referenced from:_ARCLite__load() in libarclite_iphoneos.a(arclite.o)
build settings "Implicitly Link Objective-C Runtime Support"
6.CocoaPodsのサードパーティ製ライブラリへのインポートを解決し、ヘッダファイルが見つからないことを示す
1. TARGETS -> Build Settings -> SearchPaths -> User Header Search Paths
2. '+' , ${SRCROOT}, recursive
3.Product -> Clean
7.iOS 8以上ホワイトステータスバー
ステータスバーのフォントが黒:UIstatusBarStyleDefaultステータスバーのフォントが白:UIstatusBarStyleLightContent
:
info Status bar style UIStatusBarStyleDefault
UIStatusBarStyleLightContent( UIStatusBarStyleDefault)
View controller-based status bar appearance NO。
View controller-based status bar appearance YES, Status bar style 。
8.iOS 9&iOS 10 HTTPが正常に使用できない解決方法
Info.plist NSAppTransportSecurity Dictionary。
NSAppTransportSecurity NSAllowsArbitraryLoads Boolean, YES
9.強制終了app
#pragma mark -
- (void)exitApplication
{
[UIView beginAnimations:@"exitApplication" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.window cache:NO];
[UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];
self.window.bounds = CGRectMake(0, 0, 0, 0);
[UIView commitAnimations];
}
- (void)animationFinished:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
if ([animationID compare:@"exitApplication"] == 0)
{
exit(0);
}
}