Questions about iOS development (6) and questions about ios development

Source: Internet
Author: User

Questions about iOS development (6) and questions about ios development

61. Warning "addexplicit braces to avoid dangling else"

The so-called "Dangerous else" is code similar to this:

If (a = 10)

Printf ("TEN ");

Else

Printf ("not ten ");

A = 100;

The compiler thinks that your else clause causes semantic ambiguity. What do you mean? Whether a is equal to 10 or not, if must assign a value to 100 after execution, or just assign a value to 100 in the else clause (that is, when a is not equal to 10?

If it is the former, the correct statement should be:

If (a = 10 ){

Printf ("TEN ");

} Else {

Printf ("not ten ");

}

A = 100;

If it is the latter, the correct method should be:

If (a = 10 ){

Printf ("TEN ");

} Else {

Printf ("not ten ");

A = 100;

}

Of course, for the c/c ++/java compiler, this is only a small problem and will not cause compilation failure. The compiler actually prefers the former, which is automatically handled in the first case. But it will warn you that this is a bad code style and you can ignore this warning with the # pragma clang diagnostic ignored "-Wswitch" macro, or set the compilation option MissingBraces and Parentheses to NO.

62. The Home key is not displayed on the iPad simulator.

In Xcode 4.3, the Home key is not displayed on the iPad Simulator for a larger user space. You can replace the Home key by selecting "Hardware> Home Page" or pressing the ⇧ ⌘ H shortcut.

63. Novisible @ interface for 'nsurl' declares the selector 'query'

In iOS6, this method is discarded. Use NSURL + Parameters instead.

64. certificateidentity 'iphone distribution 'appears more than once

This is a duplicate certificate error. You need to delete and compile the duplicate certificates in the key string to pass the compilation. However, if you restart Xcode, you will find that the previously deleted certificate is back. However, when you restart Xcode, the certificate in Xcode will be imported into the key string. Therefore, deleting duplicate certificates in the key string is invalid.

I believe that many of you have been so disgusted with Xcode's Bug, but there is no way to delete the certificate from the key string repeatedly (but in vain. In fact, it's not just Xcode, but it's also related to "iPhone configuration tools.

 

These "residual" certificates in Xcode do not exist in the regular form. If you have installed the "iPhone Configuration Utility", these certificates are actually stored in the/Users/km-cn/Library/MobileDevice/Applications/directory. in the app file. the app is actually the app imported from "iPhone Configuration Utility"-"application. You can use the Finder -- "show Package content" to view the. app. One file named "embedded. mobileprovision" is the "residual" duplicate certificate. You can delete these items one by one. app, you can also simply put all. all apps are deleted (you can compile these files whenever the project file exists. app and import it to "iPhone Configuration Utility ). Finally, delete the duplicate certificate in Orgnizer and restart Xcode.

65. Application Identifier 'com. ydtf. * 'which doesn' t match the current setting 'com. ydtf. dlt'

As you can see, the two Application IDs are absolutely matched (* represents a wildcard ). But this inexplicable error will make you unable to compile. This is definitely another Bug in Xcode. First, change CodeSigning to Don't Code Sign and Build, and then modify the correct signature Build.

66. Theidentity used to sign the executable is no longer valid.

Archive cannot be created due to the previous signature issue. For the solution, see question 65.

67. Use presentModalViewController in iPad to set the size of the pop-up window

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 'ortant ant to do this after presentModalViewController. That is, you must set the frame size after [selfpresentModalViewController: testVC animated: YES!

 

68. Customize the ActionSheet button and Popover arrow direction in the iPad.

ActionSheet is displayed as a pover on the iPad. The cancelButton is not displayed by default. (The SDK replaces the cancelButton with a region other than the Popover. You only need to click a region other than the pover to click 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 is displayed.

If you want 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 destructiveButtonIndex is specified, the button is displayed in red.

Do not specify cancelButtonIndex because cancelButton will be removed from the iPad.

In the iPad, the SDK does not provide an API for modifying the arrow direction of the actionSheet. The system automatically determines the direction of the arrow. However, we can use the showFromRect 1st parameter 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];

In this way, the original left arrow is replaced with the top arrow.

In fact, the logic for iOS to determine the direction of the actionSheet pop-up is very simple. If there is "enough" Space on which side, it will pop up on which side. When we use the showFromRect's 1st parameters to "Block" all three directions, it will only pop up from the desired direction honestly.

69. In ASINetworkQueue, setShowAccurateProgress = YES does not work.

Add request. showAccurateProgress = YES before networkQueue. showAccurateProgress = YES. Otherwise, showAccurateProgress will not take effect. Sample Code:

Equest. showAccurateProgress = YES;

NetworkQueue. showAccurateProgress = YES;

[NetworkQueue setsuincluded: YES];

[NetworkQueue addOperation: request];

NetworkQueue. uploadProgressDelegate = self;

[NetworkQueue go];

In addition, due to a Bug in CFNework, the exact upload/download progress of Data smaller than kb cannot be tracked.

70. How do I set the background color of UIWebView to transparent?

Setting the Background attribute of UIWebView in IB to Clear Color does not make the Background transparent. To achieve this goal, you need to use the following two sentences:

[WebView setBackgroundColor: [UIColor clearColor];

[WebView setOpaque: NO];

 


How to Adapt ios development to 6 and 7

If ([[[UIDevice currentDevice] systemVersion] floatValue]> = 7.0 ){
// Process what can be done on iOS 7 or later
}
Else {
// Process
}

How to install ios6

First, check whether your device is in the iOS6 firmware support list. According to the information published by Apple, the following devices can be successfully upgraded to iOS6:

Compared with the iOS5 firmware, iPhone 4S, iPhone 4, iPhone 3gs, iPad2, iPad3, and iPod touchs, Apple canceled the upgrade of iPad generation and iPod touch3 to the new version.

At the same time, we need to download the new version of iTunes10.6.3 specially prepared for the iOS6 firmware upgrade, and the firmware of the iOS6 beta version.
Reminder: the firmware for the iOS6 beta version is downloaded in the format of dmg. This is a compress of the disc. You can use some virtual optical drives or other software to open it, copy the firmware file in ipsw format to use it.

Having the above conditions does not mean that you can participate in the iOS6 test. because Apple only releases the iOS6 test for developers who are eligible to pay for iOS developers, if you want to experience iOS6, you must also add your device to the list of allowed devices under a developer account. As long as you know a developer, I believe he will be willing to help add your device to the developer account list, because under each developer account, you can register up to 100 iOS devices for testing (up to 500 devices under your company account ).

Of course, if you are Gao fushuai, you can register a paid developer account at Apple's Developer Center. The annual fee is only USD 99, it is one of the most charged operating systems on all mobile platforms.

With the above conditions, we can easily upgrade the iOS 6 beta version by following the steps of upgrading the iOS firmware normally.

Enable iTunes10.6.3

Connect iOS devices such as iPhone 4S to your computer
Right-click the iOS icon in the left-side menu bar of iTunes and select backup to avoid data loss.

Reminder: According to Apple's instructions, after iOS6 is upgraded, it cannot be downgraded to iOS5.

Click Shift (select the Option key under Mac), and click Restore in iTunes. In the pop-up file box, select the downloaded iOS6 firmware.
Wait patiently until the iTunes recovery is complete.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.