UI development----Target/action Design patterns and proxy design patterns and gesture recognizers

Source: Internet
Author: User

Created by Guo Chai April 16, 2015 21:50:33

Eyes a little pain, eyesight is also in rapid decline, the window of the soul, pay attention to protection!

================================================

Coupling is a measure of a program written by the standard of good or bad?
Coupling is an indicator of the degree of correlation between modules and modules
"High cohesion, low coupling" is the object-oriented programming of core ⼼ mind;

================

The idea of design patterns is important

==================

Target/action design mode:

MyView:

{    //Save object    ID _target;    Save method    SEL _action;} Assign a value to the instance variable _target and _action-(void) AddTarget: (ID) Target action: (SEL) Action;
-(void) AddTarget: (ID) Target action: (SEL) action{    _target = target;    _action = action;}
Corresponding to the call in the Touch event response:

[_target performselector:_action WithObject:self.bView];
The corresponding controller:

[MyView addtarget:self Action: @selector (changecolorandposition:)];
and implement the method.

============================================
Agent design mode idea:

The proxy design pattern is to define the proxy first, then define the class properties of the proxy in the view, and then Cotroller follow the protocol to implement the method in the Protocol

and set the Cotroller itself as an agent.

@property (nonatomic,assign) id<myviewdelegate>delegate;
============================================
Gesture Recognizer:

Gestures: a regular touch.

There are seven major categories of gesture recognizers:


The following implements a pinch gesture:

    Grip <pre name= "code" class= "OBJC" >//    uipinchgesturerecognizer * pinch = [[Uipinchgesturerecognizer alloc] Initwithtarget:self Action: @selector (pinch:)];//    //must note here is Self.view instead of self.redview//    [Self.view Addgesturerecognizer:pinch];
-(void) Pinch: (Uipinchgesturerecognizer *) pincgest{    self.redView.transform = Cgaffinetransformmakescale ( Pincgest.scale, Pincgest.scale);                NSLog (@ "hold Gestures");}


UI development----Target/action Design patterns and proxy design patterns and gesture recognizers

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.