Custom UIButton No Longer Works After Changing UIView to UIViewController
<p>This code worked in a UIView container, but after changing that container to a UIViewController, the code no longer works:</p>

<pre><code>-(void)viewDidLoad 
{
    [super viewDidLoad];

    [self.view setUserInteractionEnabled:YES];

    // set button
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(60, 30, 220, 220);
    [button setImage:self.obj.img forState:UIControlStateNormal];
    [button addTarget:self action:@selector(selected:) forControlEvents:UIControlEventTouchUpInside];
    [button setUserInteractionEnabled:YES];

    [self.view addSubview:button];
}

-(void) selected:(UIButton *) button // also tried (id) sender
{
    NSLog(@“Button Selected“);
}
</code></pre>

<p>These containers are created programmatically (dynamically), from web services, so I cannot use Storyboard. The reason for changing to a UIViewController is that I need a segue to another screen. Also, these containers are placed in a UIScrollView.</p>

<p>Everything else is working properly, except the selector.</p>

<p>Setting the userInteraction wasn't necessary earlier, but I've gone ahead and tried that in different configurations. I've added this to the scrollview, the viewController, and the button, just for good measure.</p>

<p>I even tried some online tutorials for programmatically creating UIButtons in UIViewControllers and was able to do that just fine. Not sure what the issue is here. Thanks.</p>