[Lecture Notes] Stanford University Open class: IOS 7 App Development Lecture6

Source: Internet
Author: User

1.Abstract means that this class cannot is instantiated and Used,it ' s only useful as a superclass for other classes that a Re concrete. (04:00)  2.and I also like to document,even in my implementation any methods that basically is abstract. Any method, which is required, that's override this method. and also any abstract method,you ' ve got to make them public. (05:00)  3.how do we do it? It's very simple actually,you just go to the object palette-the same place you drag a button or a slider out of,and you Drag a view Controller,and when you drag it out,it ' ll be a generic view controller. In other Words,its class would be uiviewcontroller.then-go create your subclass of uiviewcontroller.in this case,in the Demo I just did I created a subclass of a class I already had,but can create this direct subclass of Uiviewcontroller , and then your go and inspect it with the attributes inspector and your set its class. (13:00)  4.so You got all these mvcs,how does you present them to the USEr? Well,there's a number of ways to does it,but the fundamental answer is your use a controller whose view are other MVCs. (14:00)  5.a Uinavigationcontroller looks like this. It's a mvc,its controller is the Uinavigationcontroller,its view are this kind of white rectangular thing with a gray bar a T the Top.and possibly a gray bar at the Bottom,and it includes a rootviewcontroller,which are a special outlet that comes Out this points to the controller of the MVC that's going to appear in the navigation controller when it's starts up, it's R Ootviewcontroller.so When you set the is the Mvc,the navigation controller is going to the look like this. It's gonna put the view of that root view controller's MVC into-embedded inside of its view. Now,if you and then has some button or something inside this view or maybe in the bar at the top, wants to give, so more Detail and has other MVC provides,you click on that button and it slides in the view for this other Mvc,and puts a back Button there as You see. Now again,when the navigation controller's in this state,the MVC, that's on the left kind of wants to be quite. It doesn ' t want to be doing anything. The MVC completely in control. Now,of course,that Little Back button which automatically appears what do I little back button,when you press It,it ' s obviously just going to move back to the original one,then this MVC are now live again. What happened to the MVC in the right when do we clocked the back button? The answer is, it got deallocated from the heap. That MVC in the Right,got unfreeze-dried from the storyboard if we put it onscreen,and when it went bank off Screen,it G OT deallocated. (23:00)  6.segue is  very important to understand in this class. A Segue is just if you "re going to move or segue from one MVC to another. And the segue that's involved in a uinavigationcontroller is called a push segue. We kind think of the navigation controller as we push a new MVC into the Front,and maybe push another oNe,and then we pops back and pops back when we hit back button. 7.okay.so there's a problem here though. If I were to run my application on this state,it would not work. Clicking that button would not segue. Why was that? Because This whole thing have to is in a navigation controller. (31:00)  8.but you might ask,how does I get ahold of my uinavigationcontroller to send it this message and an awesome th ing about the this-is-a-to-a-is-all-is,if-a view controller and you-inside a navigation controller-anywhere on Its stack,you can get the property on yourself called Navigationcontroller and it'll return you the navigation Controlle R you ' re in. (37:00)  9.so you need to prepare the day MVC to come onscreen by telling it. Once your IT what Day,it's on its own. It just goes off,shows the day,you scroll around,you know,it ' s The one, pushes again to push in the event detail one,b UT you ' ve got to prepare it. So MVCs need to be prepared. Well,who does the PreparatioN? Obviously,it ' s the MVC that's clicked in to cause this other MVC to slide in. So in the example we just did,the MVC this has the button in It,it should had a method in It,prepareforsegue,that prepare S the next one over-the one on the right to come onscreen. The month one has to have a prepareforsegue this prepares a day view controller for coming onscreen. (39:00)  10.so when you get this preparedforsegue,the first thing your ' re going to do are look at the identifier of the Segue to see which segue we ' re talking about. Then the next thing we ' re going to say what MVC is we segueing to? Usually we going to know what class of thing it is or think we know,because we know the identifier of the segue. So it's only makes sense if you ' re in the Month view and you click on the day,that thing It;s segueing to better is a day V Iew Controller. But you still,even So,will usually do segue.destinationviewcontroller iskindofclass,the view controller we expect. Then we'll make a little loCal variable with It,and and we ' re going to do DOVC which are our local Variable,dot neededinfo equals,that ' s kind of pseu Do code for preparing the Day view controller. (40:00)  11.if The relationship between these and MVCs are "more detail" and we use a uinavigationcontroller to let them sh is the screen. But it's special because we can set its Rootviewcontroller outlet to another MVC. Then a UI element in this view (e.g. a UIButton) can segue to the other MVC and its view would now appear in the Uinavigation Controller instead. 12. " Push "is the kind of segue if the" the "and" the "controllers is inside a uinavigationcontroller. 13.sometimes it make s sense to segue directly when a button was touched,but not always. For Example,what if want to conditionally segue? You can programmatically invoke segues using method in Uiviewcontroller:
-(void) Performseguewithidentifier: (NSString *) Segueid Sender: (ID) sender; The Segueid is Set inchThe Attributes Inspectorinchxcode.the Sender isThe initiator of the segue (a UIButton or yourself (uiviewcontroller) usually).-(ibaction) rentequipment{if(Self.snowtraversingtalent = =skiing) {[Self performseguewithidentifier:@ "Askaboutskis" sender:self];}Else{[Self performseguewithidentifier:@ "Askaboutsnowboard" sender:self]; }}

14.When a segue happens,what goes on my code? The Segue offers the source VC the opportunity to "prepare" the new VC to come on screen. This method was sent to the VCS that contains the button that initiated the segue:
-(void) Prepareforsegue: (Uistoryboardsegue *) Segue sender: (ID) sender{     if ([Segue,identifier isequaltostring:@ "dosomething"]) {     ifclass]]) {     *DOVC = (DOSOMETHINGVC *= ...;}}    }

You should pass data, the new VC needs here and ' let it run '.

Think of the new VC as part of the View of the controller that initiates the segue. It must play by the same rules as a view. For Example,it should isn't talk back to you (except through blind communication like delegation). 15.

[Lecture Notes] Stanford University Open class: IOS 7 App Development Lecture6

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.