Stanford University iOS Development Course Note (part seventh)

Source: Internet
Author: User

Reprint please indicate the source

http://blog.csdn.net/pony_maggie/article/details/31462099


Author: Pony


There are so many things in this class that we introduce them in two parts. This lesson is mainly about how to develop an ipad-based application. It involves some classes, interfaces, etc. that only have ipads.


Let's start with the Uitoolbar toolbar. UI controls that are used frequently. The button on the toolbar is called Uibarbuttonitems, which can manipulate it like a button, such as setting up outlet,action. When using it, just drag it from the Toolbox to the view, assuming you want to control it dynamically. It is no problem to implement it in code. The second part of the demo program will be related to this point .

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvcg9uev9tywdnawu=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

The UI effect you see is called Split view, which has a controller class called Uisplitviewcontroller. This is only possible with the ipad app, which means that when you create a new project, you choose an ipad or Universal app to use this class . Of course, this view control is only available in the ipad-based storyboard (a project can have multiple storyboard, followed by a demo sample to see the use of this method) to pull it out. It should be understood that only the ipad has this kind of control. After all, the screen is larger than this display effect is meaningful.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvcg9uev9tywdnawu=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

Since it is split screen, the left is called the Global Column (master), the right is called the Detail bar (detail).

Uisplitviewcontroller itself has a Nsarray type property called Viewcontrollers, the first element of the array is master, and the second is detail.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvcg9uev9tywdnawu=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

Split-screen views and proxies (delegate) are never separated, assuming there is no proxy you will find the ipad vertical screen, the left column will disappear, you can not open it from anywhere (normally, is to have a button on the toolbar, click.) The left column will appear). This is shown in the following code sample. I'll talk about it.

Since this refers to the ipad vertical screen, say some more, split-screen view in the go to the vertical screen, there are two display scenarios, one of the above mentioned left column disappears, just put a button on the toolbar, click on it can be PopOver (later described) the form of pop out. The other is to show at the same time, but to "squeeze" a bit, just like the UI of the Settings feature on the ipad. The detailed use of which is based on the actual development of the function and display effect.



watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvcg9uev9tywdnawu=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

Let's finish the top three pictures at once. That's the same function.

(BOOL) Splitviewcontroller: (uisplitviewcontroller*) Sender  Shouldhideviewcontroller: (Uiviewcontroller *) Master             inorientation: (uiinterfaceorientation) orientation

This function controls whether the left column is hidden in different directions. It is easy to understand the display of different implementations from three images. Not much to say.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvcg9uev9tywdnawu=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

Control the left column how to display the need to use the proxy, the current view controller itself as a proxy. and realize

Uisplitviewcontrollerdelegate

Some of the methods in this protocol. The method mentioned above is one of them. Of course there are other ways. For example, the following:

Called when the left column is about to be hidden (for example, a horizontal screen goes to the vertical screen)-(void) Splitviewcontroller: (Uisplitviewcontroller *) svc Willhideviewcontroller: ( Uiviewcontroller *) Aviewcontroller Withbarbuttonitem: (Uibarbuttonitem *) Barbuttonitem ForPopoverController: ( Uipopovercontroller *) pc{    //Do two things    //One, set the title of the button on the toolbar to Self.title (Here is "Doctor")    //Two, put the button on the toolbar, This should be done by the right column, as only the right column is displayed at this time.        barbuttonitem.title = self.title;    [Self Splitviewbarbuttonitempresenter].splitviewbarbuttonitem = Barbuttonitem;        } Called when the left column is about to be displayed (for example, the vertical screen goes to a horizontal screen)-(void) Splitviewcontroller: (Uisplitviewcontroller *) svc Willshowviewcontroller: ( Uiviewcontroller *) Aviewcontroller Invalidatingbarbuttonitem: (Uibarbuttonitem *) barbuttonitem{    // Remove the button from the toolbar. Because the left column is displayed, there is no need for    [self splitviewbarbuttonitempresenter].splitviewbarbuttonitem = nil;}



Here's how to update the details bar. When the global column changes. There are two ways you might want to update the display in the details bar. One is very straightforward. Using Target/action, which is equivalent to a response event, is set in the handler function to be able, for example. another way to use it less often is to use segue, which is actually the equivalent of replacing the entire view of the original right-hand column. Loads a new view. Pretty little use .

This is only used in the following code demonstration sample. Be aware.

Here are some of the pop-up form (PopOver) properties, how to set, and how to change the default behavior of the pop-up form, for example, by default, popover when the user touches its area has been outside the active shutdown, can change such behavior. Simpler.


The second chapter explains the Code demonstration sample in detail.

Stanford University iOS Development Course Note (part seventh)

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.