Dealing with two common problems in iOS development

Dealing with two common problems in iOS development

[[134199]]

(I) “Unknown class XXViewController in Interface Builder file.” Problem Solution

I recently wrote a XXViewController class in a static library, and then specified the xib class as XXViewController in the main project's xib. When the program was running, the following error was reported:

  1. Unknown class XXViewController in Interface Builder file.

I encountered this problem before, but I don’t remember it clearly, so I started looking for the answer on stackoverflow again.

In fact, this problem has nothing to do with Interface Builder. The most direct reason is that the related symbols are not loaded from the static library. The solution to this problem is to add the two flags "-all_load -ObjC" in the "Build Setting" -> "Other Link Flags" of the Target, and it will be OK.

(II) Dealing with Unbalanced calls to begin/end appearance transitions for …

One of our businesses has a requirement that after entering a list, a web page needs to be pushed immediately to promote some activities. On iOS 8, our implementation is OK; but on iOS 7, we found that this web page could not be pushed, and the console gave a warning message, as follows:

  1. Unbalanced calls to begin/end appearance transitions for ...

In this case, when you click the back button in the navigation bar, a black screen is displayed directly.

We checked on stackoverflow and found this tip:

  1. occurs when you try and display a new viewcontroller before the current view controller is finished displaying.

This means that an attempt is made to display a new view controller before the current view controller has finished displaying it.

So we checked the code and found that a network request was made in viewDidLoad, and after the request returned, the web event promotion page was pushed. At this time, the current view controller may not show completion (that is, the push operation was not completed).

  1. Basically you are trying to push two view controllers onto the stack at almost the same time.

When two view controllers are pushed to the current navigation controller stack almost at the same time, or two different view controllers are popped at the same time, uncertain results will occur. Therefore, we should ensure that there is only one operation on the same navigation controller stack at the same time, and we should not push or pop a new view controller even if the current view controller is animating.

So *** we put the data request of the web activity in viewDidAppear and did some processing, so the problem was solved

<<:  The iOS promotion and operation master gave me a sudden enlightenment: how to tap into iOS channels, etc.

>>:  Beijing and Shanghai from a programmer's perspective

Recommend

Attention! Children's dry eye syndrome should not be ignored

Parents often bring their children to the ophthal...

Apple releases iOS 12 GM version: officially pushed on September 18

At Apple's Gather Round conference early this...

This fish can walk and climb trees. Where did it come from?

Today, the Qinghai-Tibet Plateau is the roof of t...

10+ Apps You Must Uninstall During the National Day Holiday

"A phone with 64GB of storage should be enou...

Kong Wei: Learn English by reading Pride and Prejudice

Kong Wei: Reading "Pride and Prejudice"...

618 Marketing Promotion Plan Creation Guide, 1 Step to Get It Done

Every marketing plan with soul must not be a pile...

How to build a high-quality community? 5 elements!

After the activities end, many communities become...

Rules for creating popular short videos on Tik Tok!

The article summarizes 36 rules for creating popu...

Is it necessarily the result of staying up late if you have “panda eyes”?

Key Points ★ Staying up late does affect dark cir...