When I was making my first iOS app, I encountered many difficulties along the way. Fortunately, I solved them all with the help of Google and StackOverflow. I don’t know if it is the best practice. Hide the Tab bar In an app that divides modules with a Tab bar, some non-first-level interfaces do not need a tab bar at the bottom. You only need to add a statement to hide the tab bar in the viewWillAppear: of the ViewController:
However, a better approach is to set the property hidesBottomBarWhenPushed to YES before pushing a ViewController:
Calculating UIScrollView's ContentSize Some UIScrollView content is dynamically increased or decreased, which requires recalculating the ContentSize. Add the following code after changing the content:
It seems that layoutIfNeeded must be executed before calculation, otherwise some sub views will not be laid out yet. Calculate the height of multiple lines of text UILabel and UITextView can display multiple lines of text. If the string is obtained dynamically, you need to calculate the height of the entire text (the width is usually fixed). At this time, you need to use the boundingRectWithSize: options: attributes: context: API (new in iOS7). In order to facilitate calling in my own project, I encapsulated it as follows:
Remove leading and trailing spaces from a string The string entered in UITextField often needs to be trimmed, which requires the following code:
Monitor UITextView input and display the number of words in real time First, you need to conform to UITextViewDelegate and display the number of words in the current UITextView in UILabel in textViewDidChange::
Set the maximum input length of UITextView Implement the textView:shouldChangeTextInRange: method in UITextViewDelegate:
|
<<: Google Now employees leave due to dissatisfaction with new CEO's restructuring plan
>>: Some tips for becoming a hardcore programmer
For thousands of years, the plum rains have creat...
Known as the Toutiao of the e-commerce industry ,...
Lung cancer is one of the malignant tumors with t...
After Wangfujing Department Store and other shopp...
During the 2017 Spring Festival travel rush, why ...
The water that flows out of an ordinary faucet te...
During the activity, users will go through proces...
1. iOS object creation and initialization Object ...
In two days it will be the 520 Festival, and on t...
What kind of preparation and capabilities are nee...
In the late 1920s, Edwin Hubble discovered that t...
The dilemma of public domain traffic can only be ...
A brief history of the development of pepper in C...
Is it possible to advertise without money? Before...
QuestMobile data shows that this year's 618, ...