Some of the best tricks for iOS development

Some of the best tricks for iOS development

Some tips for iOS

What should I do if TableView does not display cells with no content?

Like this, I don't want the empty space below to be displayed.

It's very simple.

  1. self.tableView.tableFooterView = [[UIView alloc] init];

Those who have tried it say it's good.

After adding this sentence, it becomes like this.

What should I do if the left swipe back gesture of the customized leftBarbuttonItem fails?

  1. self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
  2. initWithImage:img
  3. style:UIBarButtonItemStylePlain
  4. target:self
  5. action: @selector (onBack:)];
  6. self.navigationController.interactivePopGestureRecognizer.delegate = (id<UIGestureRecognizerDelegate>)self;

What should I do if ScrollView cannot scroll to the top of the viewController for unknown reasons?

  1. self.automaticallyAdjustsScrollViewInsets = NO;

I am so annoyed by the keyboard events I wrote that I want to throw the keyboard. What should I do?

  1. Buy a solid keyboard.
  2. I used IQKeyboardManager (searchable on github), and my waist and legs no longer hurt after using it.

Why is my app always stuck? What went wrong?

As shown

This artifact is called: KMCGeigerCounter
Go to GitHub and move it.

How to adjust the position of separaLine without creating a new Cell?

_myTableView.separatorInset = UIEdgeInsetsMake(0, 100, 0, 0);

How do I close the keyboard by clicking on self.view? Do I need to add a tapGestures?

  1. - ( void )touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  2. {
  3. [self.view endEditing:YES];
  4. }

How to set a default background image for each ViewController?

Use the base class, boy.

I want to change the layoutAttributes added in the xib in code, but how can I find it in code?

Pull your constraints like you would a button. NSLayoutAttribute can also pull lines.

How to hide the navigationbar when sliding like Safari?

navigationController.hidesBarsOnSwipe = Yes

The title of the back button on the navigation bar is so annoying, how can I make it disappear?

  1. [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake( 0 , - 60 )
  2. forBarMetrics:UIBarMetricsDefault];

CoreData is annoying to use, and the syntax is long and ugly. What should I do?

MagicalRecord

How does CollectionView implement a hovering header like tableview?

CSStickyHeaderFlowLayout

<<:  Schools of programming

>>:  Is it Lanxiang again? A major bug appeared in WeChat's "group chat" function

Recommend

Moving forward on the Android road

Counting the days, from graduation to now, I have...

User promotion: 6 common forms of bringing in new users

Today's article would like to explain to you ...

Rockchip IPO pain point: Difficulty in sustainable profitability

As an important domestic chip manufacturer, Rockc...

Who killed this land?

Agriculture is the foundation of social developme...

ASO optimization, some things you have to know when doing ASO!

1. The world is in dispute, and CPs discuss ranki...

Community operation: the key point to keep the community active!

I ate and drank too much in the first half of the...

A universal formula for user growth

I have always believed that no matter what you do...

Can’t do these 5 things? I advise you not to invest in information flow!

According to the latest data from iResearch MUT, ...

Is there any difference in speed? Win7/8.1/10 installation test

This time, our test was conducted using Ningmei&#...