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
Author: Sun Taixin, Chief Physician, Beijing Elec...
In recent years, when people talk about online ma...
When it comes to weather forecasting, artificial ...
A script is the outline needed for shooting a sho...
I have been in the Internet industry for two year...
[[156039]] Here are the most common React native ...
The girls in high buns and green clothes walked s...
When you read this title, you must want to know h...
You don’t need to download Didi, register an acco...
With the rise of knowledge payment, audio payment...
Will a credit card limit reduction be reflected i...
In the age of universal iodine supplementation, p...
We haven’t talked about the promotion methods of ...
The rainbow has been a symbol of beauty since anc...