1
votes

My application's structure is as follow:

  • UITabViewController:

    • First UIViewController:

      • UIPageViewController:

        - Page1: UIViewController:
        
                    - UIView: contains Some UILabels, 1 UIButton
        
        - Page2: UIViewController:
        
                    - UIView: contains Some UILabels, 1 UIButton
        
    • Second UIViewController:

The UIView I added programmatically in the UIViewController:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    SessionView* b = [[[NSBundle mainBundle] loadNibNamed:@"SessionView" owner:self options:nil] lastObject];
    CGRect frame = b.frame;

    b.frame = CGRectMake(0, 88, frame.size.width, frame.size.height);

    [self.view addSubview:b];
}

The weird thing is the UIView appears without its background color. And the button cannot be tapped.

missing background

I upload the source code here just in case you want to check.

I am working on iOS8, XCode6, iPad

Thanks a lot.

2
In your project, when debugging the view hierarchy you can see that the issue is not the background color. The SessionView has a height of 0, which also explains why you can't tap the button. The event can't reach it. I don't get quite why you set all this up in this specific way (instantiating from storyboard, then loading a view from xib). I will try to have a closer look this evening. - Gero

2 Answers

0
votes

try this :

  [mainview bringSubviewToFront:subview];
0
votes

image is provided below

tick mark a subview clip...............