Do programming projects, did not encounter bugs, encountered problems, basic impossible. StackOverflow is a large open FAQ platform, you are the problem maker and the answer provider. This article lists the top 15 questions about iOS (the most common) in StackOverflow so far, so that you can find the answers you want more conveniently, directly and quickly, perhaps one of the problems you've met or are about to meet.
(Here are the answers are simple descriptions, if necessary, you can go to the original question page to see the detailed answer)
First, how to put the contents of the Uilabel vertical alignment
We all know that Nstextalignment has five values:
Nstextalignmentleft; //Horizontal left
Nstextalignmentcenter; //Horizontal Center
Nstextalignmentright; //Horizontal right
Nstextalignmentjustified; //reasonable spread equal to the left
Nstextalignmentnatural; //default equivalent to left
But do not want to be in the vertical direction of the upper or lower:
Nstextalignmenttop;
Nstestalignmentbottom;
The default is the vertical center, how to achieve the home or the next?
For:
Uilabel cannot set the layout in a vertical direction, but you can achieve the salvation of the curve by SizeToFit changing the frame of the label.
Vertically align text to top within a UILabel
Http://stackoverflow.com/questions/1054558/vertically-align-text-to-top-within-a-uilabel
Ii. What is the difference between atomic and nonatomic?
as follows, atomic and nonatomic have a role in declaring member variables:
@property(nonatomic, retain) uitextfield *username;
@property(atomic, retain) uitextfield *username;
@property(retain) uitextfield *username;
For:
With Atomic, synthetic setter/getter (not self-rewriting) can often return a full value (from getter or setter), even if other threads are doing setter activity, Nonatomic does not have this guarantee. However, atomic does not guarantee thread safety, so in order to run speed and user experience, generally with nonatomic, the system default atomic.
What ' s the difference between the atomic and Nonatomic attributes?
Http://stackoverflow.com/questions/588866/whats-the-difference-between-the-atomic-and-nonatomic-attributes
How to get Uitextfield to move up when the keyboard pops up
For example, some fill in the information of the page, some Uitextfield location comparison, the keyboard pop-up will cover it, resulting in invisible input content.
For:
Move the view where the Uitextfield is located by listening to the state of the keyboard.
How do a uitextfield move up when keyboard is present?
Http://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present
Iv. How to check the network connection status of iOS or OS X devices
For:
With the help of the open source framework Tonymillion/reachability
How to check for a active Internet connection on IOS or OSX?
Http://stackoverflow.com/questions/1083701/how-to-check-for-an-active-internet-connection-on-ios-or-osx
V. Performselector: The method will cause a memory leak because it does not know the selector
Code:
[_controller performselector: nsselectorfromstring(@ "SomeMethod")];
The arc compiler gives a warning to the previous line of code:
"Performselector may cause a leak because it selector is unknown".
For:
Use the IMP and function pointer methods to solve the problem.
Performselector may cause a leak because it selector is unknown
Http://stackoverflow.com/questions/7017281/performselector-may-cause-a-leak-because-its-selector-is-unknown
Vi. How to check if there is another string in a string in objective-c
For:
After iOS8 or OS X Yosemite:
- (BOOL)containsstring:(nsstring *)str ns_available( 10_10, 8_0);
Before:
NSString *string = @ "Hello bla bla";
If ([string rangeofstring:@ "Bla"]. Location = = nsnotfound) {
NSLog(@ "string does not contain Bla");
} Else {
NSLog(@ "string contains bla!" );
}
How does I check if a string contains another string in Objective-c?
Http://stackoverflow.com/questions/2753956/how-do-i-check-if-a-string-contains-another-string-in-objective-c
Vii. How to sort a mutable array that contains custom objects
For:
Sortedarrayusingcomparator:
How to sort a nsmutablearray with custom objects in it?
Http://stackoverflow.com/questions/805547/how-to-sort-an-nsmutablearray-with-custom-objects-in-it
Eight, with automatic layout in the TableView to the dynamic cell layout and adaptive height
For:
1. Adding constraints
2. Determine the unique identifier of the cell
3. Estimated height using row (iOS8)
4. Add height cache (if required)
Using Auto Layout in UITableView for dynamic cell layouts & variable row heights
Http://stackoverflow.com/questions/18746929/using-auto-layout-in-uitableview-for-dynamic-cell-layouts-variable-row-heights
Nine, the value of the transfer between the controller
For:
Properties, proxies, block ...
Passing Data between View Controllers
Http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers
X. How to develop iphone software with Windows devices
Note: This question is seven years old, so far no answer has been adopted.
How can I develop to iPhone using a Windows development machine?
Http://stackoverflow.com/questions/22358/how-can-i-develop-for-iphone-using-a-windows-development-machine
Xi. How to disable the highlight state of the TableView cell when it is selected
For:
Cell. Selectionstyle = uitableviewcellselectionstylenone;
How can I disable the UITableView selection highlighting?
Http://stackoverflow.com/questions/190908/how-can-i-disable-the-uitableview-selection-highlighting
12, how to change the color of the status bar on the IOS7
For:
1. Set Uiviewcontrollerbasedstatusbarappearance to Yes in the. plist file.
2. Add [self setneedsstatusbarappearanceupdate] to viewdidload.
3, add the following code in the control:
- (uistatusbarstyle)preferredstatusbarstyle
{
return uistatusbarstylelightcontent;
}
How to change Status Bar text color in IOS 7
Http://stackoverflow.com/questions/17678881/how-to-change-status-bar-text-color-in-ios-7
13. How to change the name of iOS app
Note: The answer adopted is 08, is inaccurate, you can click to see the detailed answer.
What is the name of an IOS app?
Http://stackoverflow.com/questions/238980/how-to-change-the-name-of-an-ios-app
14, Xcode7 Error "iOS Publishing certificate Lost"
Package upload AppStore times the following error:
Failed to locate or generate matching signing assets
Xcode attempted to locate or generate matching signing assets and failed to do because of the following issues.
Missing IOS Distribution signing identity for ... Xcode can request one for you.
For:
First, download the installation WWDR Intermediate certificate,
Second, select the system keychain in the Keychain Access application ...
Xcode 7 Error: "Missing IOS distribution signing identity for ..."
Http://stackoverflow.com/questions/32821189/xcode-7-error-missing-ios-distribution-signing-identity-for
XV, transport security block plaintext HTTP
Error message:
Transport Security has blocked a cleartext http (http://) resource load Since it is insecure. Temporary exceptions can be configured via your app ' s info.plist file.
For:
Set allow arbitrary loads to Yes in the configuration under Project info. Then add the primary domain name you want to connect to under exception Domians.
Transport Security has Blocked a cleartext HTTP
Http://stackoverflow.com/questions/31254725/transport-security-has-blocked-a-cleartext-http
15 Questions on the StackOverflow on iOS with the most votes (most common)