71. How to make the size of UIWebView conform to the HTML content?
In iOS5, this is very simple, set the webview delegate, and then implement didFinishLoad: method in the delegate:
-(void)webViewDidFinishLoad:(UIWebView*)webView{ CGSizesize=webView.scrollView.contentSize;//iOS5+ webView.bounds=CGRectMake(0,0,size.width,size.height); }
72. There are multiple Responders in the window, how to quickly release the keyboard
[[UIApplicationsharedApplication]sendAction:@selector(resignFirstResponder)to:nilfrom:nilforEvent:nil];
In this way, all Responders can lose focus at once.
73. How to enable UIWebView to zoom through the "pinch" gesture?
Use the following code:
webview=[[UIWebViewalloc]init]; webview.autoresizingMask=(UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight); webview.scalesPageToFit=YES; webview.multipleTouchEnabled=YES; webview.userInteractionEnabled=YES;
74, Undefinedsymbols:_kCGImageSourceShouldCache, _CGImageSourceCreateWithData, _CGImageSourceCreateImageAtIndex
ImageIO.framework is not imported.
75, expectedmethodtoreaddictionaryelementnotfoundonobjectoftypensdictionary
SDK6.0 has added a "subscript" index to the dictionary, that is, retrieving objects in the dictionary through dictionary[@"key"]. But in SDK5.0, this is illegal. You can create a new header file NSObject+subscripts.h in the project to solve this problem. The content is as follows:
#if__IPHONE_OS_VERSION_MAX_ALLOWED<60000 @interfaceNSDictionary(subscripts) -(id)objectForKeyedSubscript:(id)key; @end @interfaceNSMutableDictionary(subscripts) -(void)setObject:(id)objforKeyedSubscript:(id<NSCopying>)key; @end @interfaceNSArray(subscripts) -(id)objectAtIndexedSubscript:(NSUInteger)idx; @end @interfaceNSMutableArray(subscripts) -(void)setObject:(id)objatIndexedSubscript:(NSUInteger)idx; @end #endif
76, error: -[MKNetworkEnginefreezeOperations]:messagesenttodeallocatedinstance0x1efd4750
This is A memory management error. The MKNetwork framework supports ARC, and memory management problems should not occur. However, due to some bugs in MKNetwork, this problem occurs when MKNetworkEngine is not set to the strong attribute. It is recommended that the MKNetworkEngine object be set to the strong attribute of ViewController.
77. The difference between UIImagePickerControllerSourceTypeSavedPhotosAlbum and UIImagePickerControllerSourceTypePhotoLibrary
UIImagePickerControllerSourceTypePhotoLibrary represents the entire photo library, allowing users to select all photo albums (including camera roll), while UIImagePickerControllerSourceTypeSavedPhotosAlbum only includes camera roll.
78. Warning "Prototypetablecellsmusthaveresueidentifiers"
The Identidfier attribute of Prototypecell (iOS5 template cell) is not filled in, just fill it in the attribute template.
79. How to read the value in info.plist?
The following example code reads the URLSchemes in info.plist:
//TheInfo.plistisconsideredthemainBundle. mainBundle=[NSBundlemainBundle]; NSArray*types=[mainBundleobjectForInfoDictionaryKey:@"CFBundleURLTypes"]; NSDictionary*dictionary=[typesobjectAtIndex:0]; NSArray*schemes=[dictionaryobjectForKey:@"CFBundleURLSchemes"]; NSLog(@"%@",[schemesobjectAtIndex:0]);
80. How to prevent ActionSheet from automatically disbanding?
UIActionSheet will eventually be automatically dismissed no matter what button is clicked. The best way is to subclass it, add a noAutoDismiss attribute and override the dismissWithClickedButtonIndex method. When this attribute is YES, no dismissal action is performed. When it is NO, the default dismissWithClickedButtonIndex is called:
#import<UIKit/UIKit.h> @interfaceMyAlertView:UIAlertView @property(nonatomic,assign)BOOLnoAutoDismiss; @end #import"MyAlertView.h" @implementationMyAlertView -(void)dismissWithClickedButtonIndex:(NSInteger)buttonIndexanimated:(BOOL)animated{ if(self.noAutoDismiss) return; [superdismissWithClickedButtonIndex:buttonIndexanimated:animated]; } @end
81 ,Crash when executing RSA_public_encrypt function
This problem is very strange. Using two devices, one with system 6.1 and one with 6.02, the same code works fine in version 6.02, but causes the program to crash in version 6.1:
unsignedcharbuff[2560]={0}; intbuffSize=0; buffSize=RSA_public_encrypt(strlen(cleartext), (unsignedchar*)cleartext,buff,rsa,padding);
The problem lies in this sentence:
buffSize=RSA_public_encrypt(strlen(cleartext), (unsignedchar*)cleartext,buff,rsa,padding);
6.1 System iPad is a 3G version. Due to the unstable signal of the 3G network (China Unicom 3gnet) used, the rsa public key cannot be obtained frequently, so the rsa parameter appears nil. The 6.0 system iPad is a wifi version and the signal is stable, so there is no such problem. The solution is to check the validity of the rsa parameters.
82. Warning: UITextAlignmentCenterisdeprecatediniOS6
NSTextAlignmentCenter has been replaced by UITextAlignmentCenter. There are some similar alternatives. You can use the following macro:
#ifdef__IPHONE_6_0//iOS6andlater #defineUITextAlignmentCenter(UITextAlignment)NSTextAlignmentCenter #defineUITextAlignmentLeft(UITextAlignment)NSTextAlignmentLeft #defineUITextAlignmentRight(UITextAlignment)NSTextAlignmentRight #defineUILineBreakModeTailTruncation(UILineBreakMode)NSLineBreakByTruncatingTail #defineUILineBreakModeMiddleTruncation(UILineBreakMode)NSLineBreakByTruncatingMiddle #endif
83. -fno-objc-arc cannot be set in Xcode5
Xcode5 uses ARC by default and hides the " CompilerFlags" column, so you cannot set the -fno-objc-arc option of the .m file. To display the CompilerFlags column of the .m file, you can use the menu "View->Utilities->HideUtilities" to temporarily close the Utilities window on the right to display the CompilerFlags column, so that you can set the -fno- of the .m file. objc-arc flag.
84. Warning: 'ABAddressBookCreate'isdeprecated: firstdeprecatediniOS6.0
This method will be abandoned after iOS6.0 and replaced by the ABAddressBookCreateWithOptions method:
CFErrorRef*error=nil; ABAddressBookRefaddressBook=ABAddressBookCreateWithOptions(NULL,error);
85. How to read after iOS6.0 Get your cell phone address book?
After iOS6, the AddressBook framework has changed, especially that the app needs to obtain user authorization to access the mobile address book. Therefore, in addition to using the new ABAddressBookCreateWithOptions initialization method, we also need to use the new ABAddressBookRequestAccessWithCompletion method of the AddressBook framework to know whether the user is authorized:
+(void)fetchContacts:(void(^)(NSArray*contacts))successfailure:(void(^)(NSError*error))failure{ #ifdef__IPHONE_6_0 if(ABAddressBookRequestAccessWithCompletion){ CFErrorReferr; ABAddressBookRefaddressBook=ABAddressBookCreateWithOptions(NULL,&err); ABAddressBookRequestAccessWithCompletion(addressBook,^(boolgranted,CFErrorReferror){ //ABAddressBookdoesn'tgauranteeexecutionofthisblockonmainthread,butwewantourcallbackstobe dispatch_async(dispatch_get_main_queue(),^{ if(!granted){ failure((__bridgeNSError*)error); }else{ readAddressBookContacts(addressBook,success); } CFRelease(addressBook); }); }); } #else //oniOS<6 ABAddressBookRefaddressBook=ABAddressBookCreate(); readAddressBookContacts(addressBook,success); CFRelease(addressBook); } #endif }
This method has two block parameters success and failure, respectively used to perform two situations of user authorized access: consent and disagreement.
When the code calls the ABAddressBookRequestAccessWithCompletion function, the second parameter is a block, and the granted parameter of the block is used to inform the user whether to agree. If granted is No (disagree), we call the failure block. If granted is Yes (agree), we will call the readAddressBookContacts function to further read the contact information.
readAddressBookContacts is declared as follows:
staticvoidreadAddressBookContacts(ABAddressBookRefaddressBook,void(^completion)(NSArray*contacts)){ //dostuffwithaddressBook NSArray*contacts=(NSArray*)CFBridgingRelease(ABAddressBookCopyArrayOfAllPeople(addressBook)); completion(contacts); }
First get all contacts from addressBook (the results are placed in an NSArray array), and then call the completion block (that is, the success block of the fetchContacts method). In completion we can iterate over the array.
An example of calling the fetchContacts method:
+(void)getAddressBook:(void(^)(NSArray*))completion{ [selffetchContacts:^(NSArray*contacts){ NSArray*sortedArray=[contactssortedArrayUsingComparator:^(ida,idb){ NSString*fullName1=(NSString*)CFBridgingRelease(ABRecordCopyCompositeName((__bridgeABRecordRef)(a))); NSString*fullName2=(NSString*)CFBridgingRelease(ABRecordCopyCompositeName((__bridgeABRecordRef)(b))); intlen=[fullName1length]>[fullName2length]?[fullName2length]:[fullName1length]; NSLocale*local=[[NSLocalealloc]initWithLocaleIdentifier:@"zh_hans"]; return[fullName1compare:fullName2options:NSCaseInsensitiveSearchrange:NSMakeRange(0,len)locale:local]; }]; completion(sortedArray); }failure:^(NSError*error){ DLog(@"%@",error); }]; }
即在fetchContacts的完成块中对联系人姓名进行中文排序。最后调用completion块。在fetchContacts的错误块中,简单打印错误信息。
调用getAddressBook的示例代码如下:
[AddressBookHelpergetAddressBook:^(NSArray*node){ NSLog(@"%@",NSArray); }];
86、ARC警告:PerformSelectormaycausealeakbecauseitsselectorisunknown
这个是ARC下特有的警告,用#pragmaclangdiagnostic宏简单地忽略它即可:
#pragmaclangdiagnosticpush #pragmaclangdiagnosticignored"-Warc-performSelector-leaks" [targetperformSelector:selwithObject:[NSNumbernumberWithBool:YES]]; #pragmaclangdiagnosticpop
87、'libxml/HTMLparser.h'filenotfound
导入libxml2.dylib后出现此错误,尤其是使用ASIHTTP框架的时候。在BuildSettings的HeaderSearchPaths列表中增加“${SDK_DIR}/usr/include/libxml2”一项可解决此问题。
所谓"$(SDK_ROOT)"是指编译目标所使用的SDK的目录,以iPhoneSDK7.0(真机)为例,是指/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk目录。
注意,似乎Xcode4.6以后“UserHeaderSearchPaths”(或者“AlwaysSearchUserPaths”)不再有效,因此在“UserHeaderSearchPaths”中配置路径往往是无用的,最好是配置在“HeaderSearchPaths”中。
88、错误:-[UITableViewdequeueReusableCellWithIdentifier:forIndexPath:]:unrecognizedselector
这是SDK6以后的方法,在iOS5.0中这个方法为:
[UITableViewdequeueReusableCellWithIdentifier:]
89、@YES语法在iOS5中无效,提示错误:Unexpectedtypename'BOOL':expectedexpression
在IOS6中,@YES定义为:
#defineYES((BOOL)1)
但在iOS5中,@YES被少写了一个括号:
#defineYES(BOOL)1
因此@YES在iOS5中的正确写法应当为@(YES)。为了简便,你也可以在.pch文件中修正这个Bug:
#if__has_feature(objc_bool) #undefYES #undefNO #defineYES__objc_yes #defineNO__objc_no #endif
以上就是iOS 开发百问(7)的内容,更多相关内容请关注PHP中文网(www.php.cn)!

您可以在 iOS 16 上选择哪些数字格式随着对 iOS 16.4 (beta 2) 的更改,您可以为您的 iPhone 选择三种不同的数字格式。这些格式使用空格、逗号和句点作为分隔数字中千位的符号或作为小数点。小数点是用于将值的整数部分与其小数部分分开的字符,通常由句点 (.) 或逗号 (,) 分配。千位分隔符用于将多位数的数字分成三组,通常由句点 (.)、逗号 (,) 或空格 ( ) 指定。 在最新版本的 iOS 上,您将能够应用以下任何一种数字格式作为您 iPhone 的首选选项:1,23

iOS16是Apple移动设备的重大更新,因为它不仅引入了新功能,还为iPhone14Pro和ProMax带来了独家功能。这些新款iPhone是Apple首款配备常亮显示屏的iPhone。苹果对AOD的看法略有不同,不是整个屏幕变黑,而是显示变暗,刷新率动态降低到1Hz。不用说,这并不适合世界各地的许多用户和评论者,因为大多数人会不经意地检查他们的手机,并假设这是一条通知而不是AOD。Apple似乎已经在最新版本的iOS16中认识到并纠正了这个问题,增加

浏览互联网已成为我们大多数人的第二天性,我们目前生活在一个时代,它已成为我们所做的几乎所有事情的代名词。它不仅是我们用来购物,或与亲朋好友相聚的地方,它也成为了一种宝贵的工作用具。自从COVID-19大流行开始,混合工作成为新常态以来,浏览器和通信软件已成为我们与同事之间的新纽带。而且,在我们所有流行的浏览器选择中,绝大多数用户决定使用谷歌的Chrome。现在,您不一定需要运行Microsoft支持的操作系统才能使用Chrome,因为该软件也可以在其他软件上正常运行。话虽这么说,如果您尝试在

虽然不需要的电话是日常生活的一部分,但您的 iPhone 提供了一些不同的选项来使特别顽固的来电者静音。这是在iOS 15上阻止或静音不需要的电话的方法。屏蔽电话号码可以为您减轻很多压力。一旦被阻止,您将不会收到来自被阻止号码的任何呼叫的提醒。此外,呼叫者将被允许留下语音邮件,但您不会收到已留下语音邮件的通知。打开电话应用滚动到您要阻止的号码点击号码旁边的信息图标向下滚动并点按阻止此来电者点击阻止联系人您也可以在FaceTime应用程序中按照相同的步骤来阻止持续的 FaceTime 呼叫者。被屏

微软待办已收到 iOS 更新,将版本升级至 2.75,并添加了一些值得注意的更改。最新版本的任务管理应用程序提供更流畅的体验。这是因为微软在最新版本的应用程序中引入了滚动改进。除此之外,最新版本还可能带有错误修复和改进。您可以在下面阅读完整的官方变更日志。微软待办 2.75 版几个月前,微软更新了它的 To Do iOS 应用程序,让用户更容易为他们的任务添加注释。它旨在为您的

iOS 16 已经准备好再次推动你放弃实体钱包。对 iOS 16 所做的更改包括一些仅限于美国地区的功能,但苹果也愿意将其部分功能开放给其他平台。首先,马里兰州和亚利桑那州现在支持 Apple 的数字身份验证服务 Wallet ID。除了这两个,Apple 还表示很快还会有另外 11 个,但没有任何关于哪些州的进一步信息。钱包 ID 也可以在 Uber 等应用中使用,并且不必分享您的具体信息。例如,它可以说您已超过 21 岁,但不提供您的实际年龄。Apple Wallet 中的数字密钥也可以通过

ios不是linux,ios实际上是Darwin的ARM变体,源自BSD,类UNIX内核以及Apple自己的Mach内核扩展系统;这与Linux是完全不同的,Linux是一个单片内核,所有驱动程序代码和I/O工具包都是核心内核的一部分。

苹果公司周二向开发人员发布了iOS 16.2 beta 2,因为该公司准备在 12 月向公众提供更新。正式地,它添加了新的 Freeform 协作应用程序和对 Home 应用程序的改进。在后台,9to5Mac发现 Apple 一直在开发一种新的“自定义辅助功能模式”,该模式将为 iPhone 和 iPad 提供“流线型”体验。自定义辅助功能模式这种代号为“Clarity”的新模式基本上用更精简的模式取代了 Springboard(这是 iOS 的主要界面)。该功能在当前测试版中仍对用户不可用,将


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor

Dreamweaver Mac version
Visual web development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
