Strange objective-C switch Problems

Source: Internet
Author: User

Today, when implementing a function, I encountered an extremely strange problem:

The detailed description is as follows:

A series of buttons are defined in a view, and tags are set for them. Then, all buttons are associated with the same click event, which is handled according to the button ID, the event implementation is as follows:

-(Ibaction) sendkeyhandler :( ID) sender

{


Uibutton * button = (uibutton *) sender;


Switch (button. Tag)

{


Case 20:

[Self sendkeydata: key_home];


Break;


Case 21:

 

[Sendkeyandmousedata
Sendkeydata: keyboard_menu];


Break;


Case 22:

[Sendkeyandmousedata
Sendkeydata: key_back];


Break;


Case 23:

[Sendkeyandmousedata
Sendkeydata: key_back];


Break;


Case 24:

[Self
Sendkeydata: key_dpad_up];


Break;


Case 25:

[Self
Sendkeydata: key_dpad_right];


Break;


Case 26:

[Self
Sendkeydata: key_dpad_down];


Break;


Case 27:

[Self
Sendkeydata: key_dpad_left];


Break;


Case 28:

[Self
Sendkeydata: enter];


Break;


Default:


Break;

}

}

Next, something strange happened. Every time you click a button, it always runs in the selection of its corresponding tag. If you encounter a method when you execute the first statement, it will jump to the first place where this method appears.

Thank you for your understanding of this situation.

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.