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
The rapid development of mobile Internet and smar...
When it comes to height, it can be said that it i...
The Dragon Boat Festival is coming. Every traditi...
For those of us who are into appearance, we all ju...
Growing up is often painful, but learning smartly...
"Environmental girl" Greta may be angry...
Imagine: What would the ideal neighborhood look l...
As the smart TV war is in full swing, the State A...
Author: Zhang Jianzhong, Chief Physician, Peking ...
For entrepreneurs, although mini program developm...
After nine months of waiting, Lenovo Group CEO Ya...
Affected by factors such as the epidemic and the ...
The recently popular "Frog Princess" Gu...
There was an article that went viral this morning...