Uibutton events

前端 未结 1 707
野的像风
野的像风 2021-01-27 12:29
-(void)mybuttonclick{
UGFloat p=120;
    for(int i=0;i<3;i++){   
        UIButton *aa = [UIButton buttonWithType:UIButtonTypeCustom];  
        if(i==0){        
            


        
相关标签:
1条回答
  • 2021-01-27 12:49

    You aren't telling the button about name anywhere. You could set it in the title buttons title with [aa setTitle:name forState:UIControlStateNormal]; then access it in fullscreen: with [sender currentTitle].

    If you want the message to be independent of the title you could either make your own subclass of UIButton to store the message or have a different target action for each button.

    Also, the way you are constructing the names is fragile. Something like this might be better:

    NSArray* names = [NSArray arrayWithObjects:@"ZERO",
                                               @"ONE",
                                               @"Two",
                                               @"Three",
                                               nil];
    for (NSString* name in names) {
        // Do stuff with name
    }
    
    0 讨论(0)
提交回复
热议问题