Two things to do with IOS 8: remote push and unwind Segue

Source: Internet
Author: User

Original: http://imtx.me/archives/1910.html


Yesterday I spat on Weibo: IOS 8/xcode 6 was the worst version of the developer ever. Received a great many friends to express their sympathy.

The reason for this is that. Not for the features of iOS 8 itself, instead, the extensions that iOS 8 opens and the various kits are good for developers.

I complained that Apple's recent control of software quality was not very good. The last time I sent a mobile phone to not work IOS 8.0.1 did not say. IOS 8/xcode 6 itself is full of many bugs. Xcode, as an IDE, often fails when submitting apps. For example, the other day I submitted Manico 1.4.1 version number, Xcode 6 also failed directly, and finally with Xcode 5 completed the submission.

This makes us very wohuo as a developer.

Besides. Apple's evolution in IOS is becoming more and more intense. In order to advance the new system features, Apple directly break the software's backward compatible compatibility feature after upgrade. It was really amazing to me. Let's talk about two recent encounters today.

In fact, I want to record these in Apple's WWDC should have mentioned, helpless video not all read. It is only when there is a problem to solve.

changes in the remote push mechanism

Let's say you're still using the Registerforremotenotificationtypes method to register the push function in your code. Your App is also compiled with the SDK for IOS 8. Then your App will not be able to push the feature under iOS 8 (it is available under iOS 7).

Apple has set this API to "not working" directly under IOS 8. Instead of simply marking the deprecated.

So which API to use for the remote push feature under IOS 8? With the new api:registerforremotenotifications.

However, this API will only register a remote push with a silent feature, although the APP will receive push and process after it does not have any prompts on the user interface.

So how do I end up with iOS 8 under the same remote push support as iOS 7? The following code allows push support to work in iOS 7 and iOS 8, if iOS 8 is in, and else there is iOS 7.

uiapplication *Application = [uiapplication sharedapplication];if ([Application Respondstoselector:@selector(isregisteredforremotenotifications)]) {    uiusernotificationsettings *Settings = [uiusernotificationsettings Settingsfortypes:(Uiremotenotificationtypebadge                                                                                         |Uiremotenotificationtypesound                                                                                         |Uiremotenotificationtypealert)                                                                             Categories:Nil];    [Application registerusernotificationsettings:Settings];    [Application registerforremotenotifications];} Else {    [Application Registerforremotenotificationtypes:(Uiremotenotificationtypebadge                                                     |Uiremotenotificationtypesound                                                     |Uiremotenotificationtypealert)];}

As you can see, IOS 8 divides the remotenotification of the original one step into two parts, part of which is the new "uiusernotificationsettings" introduced, and part of it. Remotenotifications.

Why should Apple design this?

Simply put, Apple unifies remotenotification and localnotification in IOS 8.

The two notifications will be unified by Uiusernotificationsettings to manage the user interface related things: tags, sounds, and reminders. In addition to the unified user interface notification, Uiusernotificationsettings also introduced the uiusernotificationcategory, allowing users to conveniently directly in the Notification To perform some quick actions on the operation (action). I haven't played this part yet, so I don't have much to say.

Anyway. It's amazing how Apple is trying to get the old API straight out of the process to push the new technology ...

changes of unwind Segue

Unwind Segue is a technique I like and use very much in Storyboard. With unwind, it is very convenient to rollback between viewcontroller at the same level (through Push) and at different levels (through Modal), with only one of the previous Viewcontroller implementing a specific unwind. Then in the current Viewcontroller run this unwind, will jump back to a previous viewcontroller, regardless of the interval of a few, can accurately jump back.

The main reason for liking this technique is that unwind is more flexible than Delegate. Viewcontroller intermediate can be separated by several, do not need to use Delegate Association, just to achieve a specific unwind method can be.

However, in IOS 8 one of them. It's very regrettable. Unwind no longer works as well as ever: Suppose your viewcontroller is based on Navigationcontroller. Now it only supports reciprocal jumps between viewcontroller at the same level (that is, by Push), and does not support viewcontroller between different levels (that is, in the form of Modal).

Apple does not have any depcated Warning, directly let Modal form of Viewcontroller run unwind not work, no matter what errors and hints ...

On this, StackOverflow has a discussion: unwind Segue not working in IOS 8

So far, there is no good way (including the accepted Answer actually not), so far I have found that the best way is to rewrite the relevant code, and then use the delegate to achieve. If you have a better idea, please remember to tell me.

PostScript

Because I was almost the same iOS 7 era just started to officially do iOS development, I do not know Apple from iOS 5 and iOS 6, from iOS 6 and iOS 7 have no similar directly to the API does not work, rather than the gradual Depr The process of ecated.

In short this time let me real experience will be to the new and old version number switch as a developer's pain, and do not say that the destruction of API compatibility is not appropriate, just IOS 8/xcode 6 in a variety of frustrating Bug let people enough headaches. Still want Apple to be able to get fewer problems in Xcode 6.1.

Next, I'm going to fit Manico's Yosemite style ...


Two things to do with IOS 8: remote push and unwind Segue

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.