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

The evolution of the Android ecosystem in the past five years

The first Android phone G1 jointly developed by G...

TensorFlow implements image completion based on deep learning

[[191845]] Table of contents ■ Introduction ■ Ste...

A complete list of middleware product models for marketing activities

There are endless definitions of marketing middle...

If you want to quickly acquire 100,000 users, just use this one channel!

Many friends who have read the article told me th...

Dingdong Maicai Product Analysis

Dingdong Maicai was launched in May 2017, focusin...

How to close the Weibo applet in WeChat?

Q: Why does Weibo sharing on WeChat become a mini...

Switching to the "Google Model": Alibaba's new path for home Internet

The concept of home Internet continues to be popu...

Dapeng M2: All-in-one is the future of VR

Oculus founder Palmer Luckey once made it clear t...

The underlying logic of fission, how to make your fission lasting and effective?

The reason I wrote this article is that I was rec...