The child viewController gesture is intercepted by the parent viewController

if you add the addChildViewController sub-viewController, there is still no response

< hr >
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(50, 200, 60, 60)];
    [btn setTitle:@"" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    [btn setBackgroundColor:[UIColor blackColor]];
    [self.view addSubview:btn];
    
    [self addChildViewController:self.imgVC];
    
}

- (void)btnClick{
    NSLog(@"");
    
}
// 
- (addImgVC *)imgVC{
    if (!_imgVC) {
        _imgVC = [[addImgVC alloc]init];
        [_imgVC.view setFrame:CGRectMake(0, 50, 375, 62)];
        [self.view addSubview:_imgVC.view];
        
    }
    return _imgVC;
}
Nov.24,2021

your call flow is still not clear, just write your [self.view addSubview:self.imgVC.view] in addChildViewController . Because when you load lazily, the process you write is to add view , and then add sub-controllers. However, the correct process is to add sub-controllers before you can add view

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e98616-16d3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e98616-16d3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?