Greetings Help, deal with the label. I want to make a multi line label, like a display, so that the information would be placed there top to bottom. Those. I click on one button information on the 1st line appears, and clicked another on the 2nd line. I found one code, but something I can’t do with it.

- (void)configureTableWithData:(NSArray*)dataObjects { [self.table setNumberOfRows:[dataObjects count] withRowType:@"mainRowType"]; for (NSInteger i = 0; i < self.table.numberOfRows; i++) { MainRowType* theRow = [self.table rowControllerAtIndex:i]; MyDataObject* dataObj = [dataObjects objectAtIndex:i]; [theRow.rowDescription setText:dataObj.text]; [theRow.rowIcon setImage:dataObj.image]; } 

}

    2 answers 2

    for example, this is how it can be done

     @interface ViewController () @property (nonatomic) UILabel *label; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 300)]; self.label.numberOfLines = 0; self.label.text = @"line"; [self.view addSubview:self.label]; UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 300, 320, 100)]; [button setTitle:@"add line" forState:UIControlStateNormal]; [button addTarget:self action:@selector(tap:) forControlEvents:UIControlEventTouchUpInside]; button.backgroundColor = [UIColor grayColor]; [self.view addSubview:button]; } - (void)tap:(id)sender { self.label.text = [NSString stringWithFormat:@"%@\n%@", self.label.text, @"another line"]; } @end 
    • Does not exceed. Pressing the second button, the information simply changes to a new one, and disappears from the first button. Maybe it's better not to do in Label ?! - Rad
    • Understood, like, that something is already there. Just how to make the name come out only once, otherwise it repeats the name every time? I have a click count. It is just necessary that the second button with the number of clicks appear from below. - Rad

    That you already got into the table. You need to put a label.numberOfLines = 1 on the first button. On the second button, label.numberOfLines = 2.

    The text for the label must contain "\ n" as a line delimiter (it’s just so convenient).

    • Does not exceed. Pressing the second button, the information simply changes to a new one, and disappears from the first button. Maybe it's better not to do in Label ?! - Rad
    • The first button simply puts label.numberOfLines = 1, the information cannot disappear from it. Apparently, you yourself accidentally hit the button. Label fits great here, if I understood the problem correctly. - Valentine