Summary of extensions added in IOS8 (i)--today's expansion

Source: Internet
Author: User

    1. Today's extension in the notification bar
    2. Share extensions
    3. Action Extension
    4. Image editing Extensions
    5. File Management Extensions
    6. Third-party keyboard extensions

Note: This tutorial is from Http://www.raywenderlich.com's iOS8 by tutorials

about app extensions, how extensions worksThe app extension is an extension of the app's functionality, and it's not independent from your original app, which means it's packaged in the App store when it's submitted to your app. Second, each extension of the app has its own API interface, as in today's extension, the system provides calls to NCWidgetController.h and NCWidgetProviding.h. Then, the app extension isn't part of your app's main process, it's a separate process, and each extension has its own separate process, and unlike the apps that run on iOS, an identical extension can run under multiple processes. to illustrate how the extension works, go to the previous diagram: which App Extension: The extended part of the wake-up Container App: An extended app that's been awakened Host app: Evoking an extended app Shared Container: Shared Data container For Example: When you call the sharing feature in an app, this app supports sharing to Sina Weibo, when Sina's extended app extension is awakened, the app you wake up to share is called the host app until you've finished sharing and finally uploaded the network data, The extension process is closed. In the extended run, it is a bridging function for exchanging data, but it does not provide communication between the two app processes, as the extension does not communicate directly with the container app. Most of the time, the Container app doesn't even run, which also guarantees a lightweight extension. if the extension must communicate with the container app, there are several ways to do this:
1 // 1. Call OpenURL (), which is a method of uiapplication, however, there is no UIApplication object in the extension, Apple provides a new interface: In Nsextensioncontext, there are the following methods: 2 -(void) OpenURL: (Nsurl *) URL Completionhandler: (void (^) (BOOL success)) Completionhandler3//2. Create a shared data container: Use Nsuserdefaults to access and create a file directly responsible for data access 
The Today extension in the notification bar (Today Extensions)

In IOS8, developers can customize the display of their app's today interface in the notification bar, such as:


developers in their own app named Todayviewcontroller can customize any interface display, including Uilable, UIButton, Uiimageview and so on basic views, can also customize TableView and other complex views, Here is a demo with a currency app. This is a bit coin app, first the original app interface is as follows:
Show today's bitcoin quote and percentage change in the app, below shows the last one months of the chartWhat we're going to do is show this view in the today extension in the notification bar, first in Xcode file->new->target
after creating the name of your app extension, a dialog box will appear asking you "If you want to" Activate BTC Widget scheme? ".
after clicking Activate, a folder will be added:
This is where you set the VC portion of today's extended interface, it should be noted that the files in the new project can contain the original header file, but after you use Xcode will report a compilation error at this time, the original in the build The phases contains only TODAYVIEWCONTROLLER.M, where you need to manually add additional. m files that you need to be able to design your interface later on Maininterface.storyboard, where you set up the Uilabel, UIButton, UIView, and the general interface settings are exactly the same then in the Todayviewcontroller operator interface, directly run can be in the notification bar today to add the corresponding extension project
1 //several methods in the final description of the ncwidgetproviding2 //The following method is the refresh setting for today's extended3- (void) Widgetperformupdatewithcompletionhandler: (void(^) (ncupdateresult result)) Completionhandler {4     //If An error was encountered, use ncupdateresultfailed5     //If There ' s no update required, use Ncupdateresultnodata6     //If There ' an update, use Ncupdateresultnewdata7 [self updatewithcurrencydata];8 Completionhandler (ncupdateresultnewdata);9 }Ten //The following method sets the offset to the left of the interface One-(Uiedgeinsets) Widgetmargininsetsforproposedmargininsets: (uiedgeinsets) defaultmargininsets { A   returnUiedgeinsetszero;//fills the left default white area - } - //The following methods are used to implement vibrancy effects the+ (Uivibrancyeffect *) Notificationcentervibrancyeffect;

Realize source code: Click

Summary of extensions added in IOS8 (i)--today's expansion

Related Article

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.