iOS fourth day (6: Answer area button click and Disorderly Order)

Source: Internet
Author: User

#pragmaMark-Answer Area button click Method-(void) Answerclick: (UIButton *) button{//1. If the button does not have a word, return directly    if(Button.currentTitle.length = =0)return; //2. If there is a word, clear text, the Candidate Area button displays//1> using the title of the button to find the corresponding button in the candidate areaUIButton *btn =[self optionButtonWithTilte:button.currentTitle ishidden:yes]; //2> Display the corresponding buttonBtn.hidden =NO; //3> Clear the text of a button[Button Settitle:@""Forstate:uicontrolstatenormal]; //4> Just click on the text on the button, meaning the content of the answer area is incomplete[self Setanswerbuttonscolor:[uicolor blackcolor];}-(UIButton *) Optionbuttonwithtilte: (NSString *) title Ishidden: (BOOL) ishidden{//Traverse all the buttons in the candidate area     for(UIButton *btninchself.optionsView.subviews) {if([Btn.currenttitle isequaltostring:title] && Btn.ishidden = =Ishidden) {            returnbtn; }    }    returnNil;}//Disorderly Order- (void) randamoptions{//chaotic ordering of options arraysSelf.options = [Self.options sortedarrayusingcomparator:^nscomparisonresult (NSString *str1, NSString *str2) {        intSeed = Arc4random_uniform (2); if(seed) {return[str1 COMPARE:STR2]; } Else {            return[str2 COMPARE:STR1];    }    }]; NSLog (@"%@", self.options);}-(Instancetype) Initwithdict: (Nsdictionary *) dict{ Self=[Super Init]; if(self) {[self setvaluesforkeyswithdictionary:dict]; //Random order of the alternate button, only in the time of loading, do a disorderly sequence[self randamoptions]; }    returnSelf ;}

Click events

@implementation Hmviewcontroller /* * Not able to interact with  alpha <= 0.01 hidden = YES userinteraction =  no* /-(ibaction) Click {    NSL OG (@ "%s", __func__);} @end

iOS fourth day (6: Answer area button click and Disorderly Order)

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.