美文网首页iOS 开发 00『 基础知识 』iOS Developer
iOS开发过程中遇到的一些问题 记录一下!

iOS开发过程中遇到的一些问题 记录一下!

作者: 熊猫小贼_ | 来源:发表于2016-07-28 11:51 被阅读0次

经常在开发过程中遇到一些奇葩的问题
这边做一个总结,记录一下开发过程中踩过的坑


1.保证列表起点的Y坐标是在 nav 下边

if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) { // 这行代码是 保证列表起点的Y坐标是在 nav 下边 () self.edgesForExtendedLayout = UIRectEdgeNone; }


2.app内跳转系统设置app相关内容
os系统中各种设置项的url链接

在代码中调用如下代码:

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

[[UIApplication sharedApplication] openURL:url];

即可跳转到设置页面的对应项。

[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推送证书,用于自己搭建推送服务器的时候,跟后端匹配证书问题
具体步骤如下:

首先,需要一个pem的证书,该证书需要与开发时签名用的一致。 具体生成pem证书方法如下:

1. 登录到 iPhone Developer Connection Portal(http://developer.apple.com/iphone/manage/overview/index.action)并点击 App IDs

2. 创建一个不使用通配符的 App ID 。通配符 ID 不能用于推送通知服务。例如,  com.itotem.iphone

3. 点击App ID旁的“Configure”,然后按下按钮生产 推送通知许可证。根据“向导” 的步骤生成一个签名并上传,最后下载生成的许可证。

4. 通过双击.cer文件将你的 aps_developer_identity.cer 引入Keychain中。

5. 在Mac上启动 Keychain助手,然后在login keychain中选择 Certificates分类。你将看到一个可扩展选项“Apple Development Push Services”

6. 扩展此选项然后右击“Apple Development Push Services” > Export “Apple Development Push Services ID123”。保存为 apns-dev-cert.p12文件

7. 扩展“Apple Development Push Services” 对“Private Key”做同样操作,保存为 apns-dev-key.p12 文件。

8. 需要通过终端命令将这些文件转换为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. 如果你想要移除密码,要么在导出/转换时不要设定或者执行:

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

10. 最后,你需要将键和许可文件合成为apns-dev.pem文件,此文件在连接到APNS时需要使用:

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


4.筛选某个viewcontroller

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

{

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

{

[tempNavBarItems removeFromParentViewController];

}

}


5.判断一个坐标点是否在一个无规则的多边形内

//    在范围内返回1,不在返回0

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

intn=arrSome.count;

floatvertx[n];

floatverty[n];

for(inti=0; i

//MyPoint类存储的是经度和纬度

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;

}

//多边形由边界的坐标点所构成的数组组成,参数格式 该数组的count,  多边形边界点x坐标 的组成的数组,多边形边界点y坐标 的组成的数组,需要判断的点的x坐标,需要判断的点的y坐标

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 开发去除 UserInterfaceState.xcuserstate 文件为版本控制带来的困扰

原理和操作步骤见如下转载的两篇文章,

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

这个版本包含一个多人开发的bug

bug 的解决方案见我之前转载的两篇文章~

另外就是如本文转载的第一篇文章,我也深受 UserInterfaceState.xcuserstate 文件频繁更新带来的困扰,

要免除该困扰,可在 Versions 的配置文件~/.subversion/config 中忽略对 xcuserstate 类型文件的版本控制。

另外,Versions 的配置文件是处于隐藏目录的,可在 Finder 中通过 cmd + shift + g 直接跳到隐藏目录~

************************ 分割线 ***************************

文章标题:

摆脱 UserInterfaceState.xcuserstate给Xcode 版本控制(git)带来的困扰

转载自:http://alexrezit.42qu.com/10280223

今天在Xcode中Commit的时候UserInterfaceState.xcuserstate这个文件几秒钟更新一次, 搅得人不得安宁, 用.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

搞定!

************************ 分割线 ***************************

文章标题:

XCode SVN

转载自: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使用时需要配置Subversion。Leopard中自带了SVN,但Xcode的项目文件中,并不是所有文件都适于加入SVN中进 行管理,比如编译后的文件和编译过程中产生的文件,这些文件不属于源代码,应该告诉svn忽略掉,方法:编辑~/.subversion/config文 件

1.找到global-ignores一行,去掉注释,编辑成

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

Xcode项目文件中有些文件是文本文件,需要告诉SVN,因为SVN能更好地管理文本文件(谁用谁知道)

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.对于 输入框为空及输入参数只有空格的判断 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);//创建要剪切的矩形框这里你可以自己修改

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)];

相关文章

  • H5端与原生混合开发遇到的一些问题

    在与原生安卓/IOS实现混合开发时,会遇到一些问题,在此做下记录(以下是目前遇到的或之前有记录到的一些问题,后续如...

  • 入坑

    从今天开始,记录在iOS开发遇到的一些问题和一些解决方法

  • iOS逆向入门准备

    接触了一个多星期的iOS逆向,决定花点时间写点东西来介绍一下入门的工具和记录一下学习过程中遇到的一些问题。 越狱 ...

  • Flutter 环境配置 - cmdline-tools com

    刚学flutter,配置了一下开发环境,遇到一些问题,供参考 我用的mac 平时开发anroid,ios,前端,所...

  • iOS开发过程中遇到的一些问题 记录一下!

    经常在开发过程中遇到一些奇葩的问题这边做一个总结,记录一下开发过程中踩过的坑 1.保证列表起点的Y坐标是在 nav...

  • iOS14适配

    开发中遇到的问题, iOS14已经发布,记录一下开发中遇到的问题.不定时更新,欢迎大家评论补充. iOS14适配总...

  • iOS蓝牙项目开发

    最近公司做一个项目用到蓝牙的知识,这里简单的记录一下和开发过程中遇到的一些问题。一、基础知识蓝牙(Bluetoot...

  • iOS10中苹果的坑和Bug

    前言 iOS10已经出来好几个月了,在开发的过程中遇到了一些Xcode的坑和iOS10中的bug,在这里记录一下。...

  • 小程序开发当中踩到的坑

    为了参加微信小程序开发大赛,了解了微信小程序的开发,在实际的开发过程中遇到了一些问题,以此记录,避免再犯! 简述 ...

  • iOS开发笔记

    原文请见github上iOS开发笔记 iOS开发笔记 记录了在iOS开发中踩过的坑和一些问题解决 微信的openi...

网友评论

    本文标题:iOS开发过程中遇到的一些问题 记录一下!

    本文链接:https://www.haomeiwen.com/subject/cfjajttx.html