iOS development questions (6)
61. Warning "adexplicit braces to avoid dangling else"
The so-called "dangerous else" is code similar to this:
i
f(a== 10) printf("TEN"); else printf("NOT TEN"); a = 100;
The compiler thinks that your else clause causes semantics Not sure, what do you mean? Regardless of whether a is equal to 10, a should be assigned a value of 100 after if is executed, or do you only want a to be assigned a value of 100 in the else clause (that is, when a is not equal to 10)?
If it is the former, the correct way to write it should be:
if(a== 10) { printf("TEN"); }else{ printf("NOT TEN"); } a= 100; 如果是后者,正确的写法应该是: if(a== 10) { printf("TEN"); }else{ printf("NOT TEN"); a = 100; }
Of course, for the c/c++/java compiler, this is just a small problem and will not lead to failure to compile. The compiler actually prefers the former, and it automatically handles the first case. But it will warn you that this is a bad coding style. You can ignore this warning with the #pragma clang diagnostic ignored "-Wswitch" macro, or set the compile option MissingBraces and Parentheses to NO.
62. The iPad simulator does not display the Home button
Starting from Xcode 4.3, in order to obtain more space available to the user, the iPad simulator does not display the Home button. You can replace the Home button through the menu "Hardware > Home" or the shortcut key ⇧⌘H.
63. Novisible @interface for 'NSURL' declares the selector 'query'
In iOS6, this method is abandoned, please use NSURL+Parameters instead.
64. certificateidentity 'iphone distribution' appears more than once
This is a duplicate certificate error. You need to delete the duplicate certificates in the keychain before compilation can pass. However, if you restart Xcode, you will find that the previously deleted certificate is back. But when Xcode is restarted, the certificate in Xcode will be imported into the keychain, so just deleting the duplicate certificate in the keychain is ineffective.
I believe that many students are disgusted by this bug in Xcode, but there is no other way except repeatedly (but in vain) deleting the certificate from the keychain. In fact, we can’t blame Xcode alone, but it also has something to do with the “iPhone Configuration Utility Tool”.
These "residual" certificates in Xcode do not exist in regular form. If you installed the "iPhone Configuration Utility", these certificates actually exist in the .app files in the /Users/km-cn/Library/MobileDevice/Applications/ directory. These .apps are actually the "iPhone Configuration Utility" ——The imported app in "Applications". You can use Finder - "Show Package Contents" to view the .app. One of the files named "embedded.mobileprovision" is a "residual" duplicate certificate. You can delete these .apps one by one, or simply delete all .apps in the directory (anyway, as long as the project file exists, you can compile these .apps at any time and import them into the "iPhone Configuration Utility"). Finally, delete the duplicate certificates in Orgnizer and restart Xcode.
65, Application Identifier 'com. ydtf.*' which doesn't match the current setting 'com.ydtf.dlt'
As you can see, these two Application IDs definitely match (* represents a wildcard character ). But this inexplicable error will cause you to never compile. This is definitely another bug in Xcode, first modify CodeSigning to Don't Code Sign, Build, and then modify it back to the correct signature Build.
66. The identity used to sign the executable is no longer valid.
Due to the previous signature problem, it cannot be archived. See question 65 for the solution.
67. Use presentModalViewController to set the size of the pop-up window on iPad
TestViewController*testVC = [[TestViewController alloc] initWithNibName:@"TestViewController"bundle:nil]; testVC.modalPresentationStyle= UIModalPresentationFormSheet; testVC.modalTransitionStyle= UIModalTransitionStyleCrossDissolve; [selfpresentModalViewController:testVC animated:YES]; testVC.view.superview.frame= CGRectMake(0, 0, 649, 397);//it's important to do this afterpresentModalViewController testVC.view.superview.center = self.view.center;
Note: //it'simportant to do this after presentModalViewController. That is, the frame size must be set after [selfpresentModalViewController:testVC animated:YES];!
68. Customize ActionSheet buttons and Popover arrow directions on iPad.
ActionSheet is displayed in Popover mode on iPad. The cancelButton will not be displayed by default (the SDK uses the area outside the Popover instead of the cancelButton. As long as the user clicks on the area outside the Popover, it is equivalent to clicking the Cancel button). If you init an ActionSheet like this:
UIActionSheet* sheet=[[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"cancel" destructiveButtonTitle:@"ok" otherButtonTitles:nil];
, only the red destructiveButton will be displayed in the end.
If you have to display cancelButton, you can do this:
UIActionSheet* sheet=[[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"cancel",@"ok",nil]; // sheet.cancelButtonIndex=0; sheet.destructiveButtonIndex=1;
After specifying destructiveButtonIndex, the button is displayed in red.
But never specify cancelButtonIndex, because cancelButton will be removed on iPad.
On iPad, the SDK does not provide an API that can modify the arrow direction of actionSheet. The system automatically determines the direction of the arrow display. But we can use the first parameter of showFromRect to change the direction of the arrow:
CGRect r=sender.bounds; r.size.width=2*self.view.bounds.size.width; r.origin.x=-self.view.bounds.size.width+sender.bounds.size.width/2+sender.frame.origin.x; [sheet showFromRect:r inView:sender animated:YES];
This will replace the original left arrow with an up arrow.
In fact, the logic of iOS when judging the pop-up direction of actionSheet is very simple. Wherever there is "enough" space, it will pop up there. When we use the first parameter of showFromRect to "block" all three directions, it can only pop up from the direction we want.
69. setShowAccurateProgress=YES does not work in ASINetworkQueue
Add request.showAccurateProgress= YES before networkQueue.showAccurateProgress= YES, otherwise showAccurateProgress will not take effect. Sample code:
equest.showAccurateProgress=YES; networkQueue.showAccurateProgress=YES; [networkQueue setSuspended:YES]; [networkQueue addOperation:request]; networkQueue.uploadProgressDelegate=self; [networkQueue go];
此外,由于 CFNework 中的一个 Bug,对于小于128K的数据,无法跟踪其上传/下载的精确进度。
70、如何设置 UIWebView 背景色为透明?
在IB中设置 UIWebView 的 Background 属性为 Clear Color 并不能使其背景透明。要达到这个目的,你需要使用以下两句:
[webView setBackgroundColor:[UIColor clearColor]];[webView setOpaque:NO];
以上就是iOS 开发百问(6)的内容,更多相关内容请关注PHP中文网(www.php.cn)!

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The annual WWDC has ended, and iOS18 is undoubtedly the focus of everyone's attention. Currently, many iPhone users are rushing to upgrade to iOS18, but various system bugs are making people uncomfortable. Some bloggers said that you should be cautious when upgrading to iOS18 because "there are so many bugs." The blogger said that if your iPhone is your main machine, it is recommended not to upgrade to iOS18 because the first version has many bugs. He also summarized several system bugs currently encountered: 1. Switching icon style is stuck, causing the icon not to be displayed. 2. Flashlight width animation is often lost. 3. Douyin App cannot upload videos. 4. WeChat message push is delayed by about 10 seconds. 5 . Occasionally, the phone cannot be made and the screen is black. 6. Severe fever.

According to news on July 31, Apple issued a press release yesterday (July 30), announcing the launch of a new open source Swift package (swift-homomorphic-encryption) for enabling homomorphic encryption in the Swift programming language. Note: Homomorphic Encryption (HE) refers to an encryption algorithm that satisfies the homomorphic operation properties of ciphertext. That is, after the data is homomorphically encrypted, specific calculations are performed on the ciphertext, and the obtained ciphertext calculation results are processed at the same time. The plaintext after state decryption is equivalent to directly performing the same calculation on the plaintext data, achieving the "invisibility" of the data. Homomorphic encryption technology can calculate encrypted data without leaking the underlying unencrypted data to the operation process.

Thanks to netizens Ji Yinkesi, xxx_x, fried tomatoes, Terrence, and spicy chicken drumsticks for submitting clues! According to news on July 27, Apple today re-released the iOS/iPadOS 18 Beta 4 update for developers. The internal version number was upgraded from 22A5316j to 22A5316k. It is currently unclear the difference between the two Beta 4 version updates. Registered developers can open the "Settings" app, enter the "Software Update" section, click the "Beta Update" option, and then toggle the iOS18/iPadOS18 Developer Beta settings to select the beta version. Downloading and installing the beta version requires an Apple ID associated with a developer account. Reported on July 24, iO

Update: Saunders Tech has uploaded a tutorial to his YouTube channel (video embedded below) explaining how to install Fortnite and the Epic Games Store on an iPad outside the EU. However, not only does the process require specific beta versions of iO

According to news on June 1, technology media AppleInsider published a blog post today, stating that Apple will launch a new navigation function of "Scenes" for the "Freeform" application extension in the iOS18 system, and add new options for object alignment. Introduction to the "Wubianji" application First, let's briefly introduce the "Wubianji" application. The application will be launched in 2022 and has currently launched iOS, iPadOS, macOS15 and visionOS versions. Apple’s official introduction is as follows: “Boundless Notes” is an excellent tool for turning inspiration into reality. Sketch projects, design mood boards, or start brainstorming on a flexible canvas that supports nearly any file type. With iCloud, all your boards

Practical sharing... As Apple continues to launch new iOS versions, many iPhone users are faced with the choice of whether to upgrade the system. The release of the latest iOS17.5Beta3 has attracted widespread attention, especially for iPhone12 users. Whether they should abandon the existing iOS16 and try the new Beta version has become a question worth discussing. Based on actual experience, this article analyzes the pros and cons of upgrading iPhone 12 to iOS 17.5 Beta 3 to provide a reference for the majority of Apple fans. First of all, we need to make it clear that Beta versions are usually used by developers or early adopters who are willing to take a certain risk. This means that compared to the official version, the Beta version may contain

Thanks to netizens Spicy Chicken Leg Burger, Soft Media New Friends 2092483, Handwritten Past, DingHao, Xiaoxing_14, Wowotou Eat Big Kou, Feiying Q, Soft Media New Friends 2168428, Slades, Aaron212, Happy Little Hedgehog, Little Earl, Clues for the little milk cat that eats fish! [Click here to go directly to the upgrade tutorial] According to news on July 24, Apple today pushed the iOS/iPadOS18 developer preview version Beta4 update (internal version number: 22A5316j) to iPhone and iPad users. This update is 15 days after the last release. . Carplay Wallpaper Apple has added wallpapers to CarPlay, covering light and dark modes. Its wallpaper style is similar to iPhone

[Click here to go directly to the upgrade tutorial] According to news on May 8, Apple pushed the iOS17.5RC update (internal version number: 21F79) to iPhone users today. This update is 70 days away from the last release. How to upgrade iOS/iPadOS/watchOS/macOS development version and public beta version? To upgrade the iOS/iPadOS17 developer preview version and public beta version, you can refer to the experience shared by friends: Experience Post 1||Experience Post 2||Experience Post 3||Experience Post 4. Starting from the iOS/iPadOS 16.4 Developer Preview Beta 1, you need to register for the Apple Developer Program. After registration, open the system [Settings] [Software Update] to see the upgrade option. Please note that your iPhone or IP
