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
This article is reproduced from the public accoun...
With the rapid development of smart TVs in recent...
Difficulty falling asleep, shallow sleep, dreamin...
Soy milk is a popular healthy drink and is also k...
In the era of mobile Internet, the mobile game in...
In daily life, we often put the fruits we buy hom...
Many Douyin merchants always face the dilemma of ...
Baidu Encyclopedia started in 2006. When it was f...
How popular is WPS in the country? An office soft...
The latest practical course on making money with ...
In the process of SEO promotion, the problem that...
The main reason that affects the conversion rate ...
How finance creates value for enterprises -- Intr...
The "chip king" SMIC (688981.SH, 00981....