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
"Jiuquan radar tracking is normal!" ===...
Resource introduction of equity incentive and equ...
"High price to buy V, if you don't want ...
Recently, it was learned from the Shenyang Munici...
Compiled by: Gong Zixin Obesity is a significant ...
Your browser does not support the video tag Autho...
When checking keyword rankings during website opt...
In the May 24, 2024 issue of Science magazine, an...
All-solid-state batteries, a technology that has ...
Review expert: Wu Xinsheng, deputy chief physicia...
Someone asked, what is the job of operations? In ...
Recently, snowfall occurred in Qinghai, Heilongji...
Audit expert: Taozi National Psychological Counse...
Today, if it weren’t for the US election, if Trum...
The topic of growth has been mentioned repeatedly...