Objective-C» comment '%± %%%%%%%%%%£ 5©Protocol

Source: Internet
Author: User

Objective-C» comment '± ± Ç ç£5 £5 Protocol

Protocol quota limit ä;{{{{±' úáí £°delegation) ä£;;{£;

~Úios ° íos X ~~~~~£ ******************************************** Ö ömöshortview

Â Ã Î Ç ç ************************************************************* please refer to the following link for more information: £ ***********************************************************

~×» Ö ö° '{£ £****â £°

 
  
 
package com.example.helloword;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.view.View.OnLongClickListener;import android.widget.Button;import android.widget.Toast;public class MainActivity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        Button button = (Button) findViewById(R.id.mybutton);        button.setOnClickListener(new MyOnClickListener());    }        class MyOnClickListener implements OnClickListener{@Overridepublic void onClick(View arg0) {Toast.makeText(MainActivity.this, "µã»÷ÁË°´Å¥", Toast.LENGTH_SHORT).show();}    }        class MyonLongClickListener implements OnLongClickListener{@Overridepublic boolean onLongClick(View arg0) {Toast.makeText(MainActivity.this, "³¤°´ÁË°´Å¥", Toast.LENGTH_SHORT).show();return false;}        }}
OnClickListener Ç çview µää» ö öäú² À à £;{ç çview? ö {µää» ö öó Ó ~ú£. ç'{{onclicklistener }'  ~~~â £°

    /**     * Interface definition for a callback to be invoked when a view is clicked.     */    public interface OnClickListener {        /**         * Called when a view has been clicked.         *         * @param v The view that was clicked.         */        void onClick(View v);    }
Î Ò Ç À 'hangzhou' setOnClickListener · listener

    public void setOnClickListener(OnClickListener l) {        if (!isClickable()) {            setClickable(true);        }        getListenerInfo().mOnClickListener = l;    }
~~~~~~~View ~%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% æ äçá» Ä ä£;getlistenerinfo (). mOnClickListener = 1;

    ListenerInfo getListenerInfo() {        if (mListenerInfo != null) {            return mListenerInfo;        }        mListenerInfo = new ListenerInfo();        return mListenerInfo;    }
Ó Õ â ¶ ************************************************************** Á áw.listenerinfor has been added to ó óömámách?£ä äçách' ListenerInfor has been added to ó Ó Ç çó À 'é éâ Ï μäø £ó Ó ó ******************************************************************* ****************************************************** ¦ Á áä» μ Ä» ÷ Ê Â ¼ µ μ? Ó {onclick · {â '{{{{{{{{{{{{öá{onclickelistener Ó ó~úzä~~~~ó {£

Ó Ï Â À 'Î Ç çà 'ä£äâ Ò» â  IOS öð °' {¥ À à Ì {µäµ μ Ö ö¡ £.


Button. h Î ä¼ þ

<Symbol · blank "http://www.bkjia.com/kf/ware/vc/" target = "_ blank" class = "keylink"> vcD48cHJlIGNsYXNzPQ = "brush: java;"> # import @ Class Button; // <> 'ú± í µ μ Ï öä³ öð {}é // â À ï à ± óúonclicklistener @ protocol ButtonDelegate // When «Button has been added to ó Ó '«μ Ý ø ¼ à Ì £ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% micro-(void) onClick :( Button *) btn; @ end @ protocol ButtonLongClickDelegate -(Void) onLongClick :( Button *) btn; @ end @ interface Button: NSObject // delegate Í í Ç ç° '{¥zäà à {{}}// id 'ú±íè {° OC {ó ó @ property (nonatomic, retain) id Delegate; @ property (nonatomic, retain) id LongClickDeleate; // ä£äzäâ {µí {μ Ó click · ←-(void) click; // ä£äâ ************longclick · standards-(void) longclick; @ endButton. m Î ä¼ þ

#import "Button.h"@implementation Button- (void)click {    //°´Å¥±»µã»÷ÁË£¬¾ÍÓ¦¸Ã֪ͨ¼àÌýÆ÷£¨ÕâÀïÊÇÄ£Ä⣠   //Èç¹ûonClick·½·¨±»ÊµÏÖ£¬µ÷ÓÃonClick·½·¨    if([_delegate respondsToSelector:@selector(onClick:)]){        [_delegate onClick:self];    }else{        NSLog(@"onClick¼àÌýÆ÷δʵÏÖ");    }}- (void)longClick {    //°´Å¥±»³¤°´£¨Ä£Äâϵͳ£    if([_delegate respondsToSelector:@selector(onClick:)]){        [_longClickDeleate onLongClick:self];    }else{        NSLog(@"longClick¼àÌýÆ÷δʵÏÖ");    }}- (void)dealloc {    [_delegate release];    [_longClickDeleate release];    [super dealloc];}@end
ButtonListener. h

#import 
 
  @protocol ButtonDelegate;//ʵÏÖ°´Å¥µã»÷ÐÒé@interface ButtonListener : NSObject 
  
   @end
  
 
ButtonListener. m

#import "ButtonListener.h"#import "Button.h"@implementation ButtonListener- (void)onClick:(Button *)btn {    NSLog(@"°´Å¥±»µã»÷ÁË");}@end
ButtonLongClickListener. h Î ä¼ listener

#import 
 
  //¶ÔÐÒé½øÐÐÌáÇ°ÉùÃ÷£¬¸ú@classµÄÓÃ;ÊÇÒ»ÑùµÄ@protocol ButtonLongClickDelegate;@interface ButtonLongClickListener : NSObject 
  
   @end
  
 
ButtonLongClickListener. m Ä ä¼ listener

#import "ButtonLongClickListener.h"#import "Button.h"@implementation ButtonLongClickListener- (void)onLongClick:(Button *)btn{    NSLog(@"°´Å¥±»³¤°´ÁË");}@end
Main. m Î ä¼ þ

#import 
 
  #import "Button.h"#import "ButtonListener.h"#import "ButtonLongClickListener.h"int main(int argc, const char * argv[]) {    @autoreleasepool {        //³õʼ»¯Ò»¸ö°´Å¥        Button *button = [[[Button alloc] init] autorelease];        //³õʼ»¯Ò»¸ö°´Å¥µÄ¼àÌýÆ÷        ButtonListener *listener = [[[ButtonListener alloc] init] autorelease];        //³õʼ»¯Ò»¸ö°´Å¥³¤°´¼àÌýÆ÷        ButtonLongClickListener *longClickListener =            [[[ButtonLongClickListener alloc] init] autorelease];        //ÉèÖð´Å¥µÄ¼àÌýÆ÷        button.delegate = listener;        //ÉèÖó¤°´°´Å¥¼àÌýÆ÷        button.longClickDeleate = longClickListener;        //µã»÷°´Å¥        [button click];        //³¤°´°´Å¥        [button longClick];    }    return 0;}
 
Ê ämömámím=£°

13:52:35. 215 ProtocalTest [845: 82273] ° '00000000000000'» μ limit» maquá limit

13:52:35. 216 ProtocalTest [845: 82273] ° '000000000000000000000000000000000000000000'


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.