Why doesn't my UIButton appear?

This is the code I'm using:

UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(100, 200, 50, 70)]; [self.view addSubview:button]; if (buttonArray == nil) { buttonArray = [[NSMutableArray alloc] init]; } [buttonArray addObject:button]; [button release]; 

However, the sound display is not displayed. Any ideas why?

+4
source share
1 answer

You initialize this incorrectly. Try the following:

 UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = CGRectMake(100, 200, 50, 70); [self.view addSubview:button]; if (buttonArray == nil) { buttonArray = [[NSMutableArray alloc] init]; } [buttonArray addObject:button]; 
+8
source

Source: https://habr.com/ru/post/1343391/


All Articles