1

I'm new to mac development. I've used NSSplitView to divide my view. when I select the field from the left side of split view, the selected view has been displayed on the right side of split view.

Now the problem is that when I press an button on the selected view controller on the righ to go from that view controller to another the action is not been performed.

- (IBAction)newProductAction:(id)sender {
    [self replaceViewWithCurrentView:@"nP" productImageValue:0 andProductId:([ItemModel getMaxValueOfItemIdFromItemBit:[appDelegate getDBPath]] + 1)];
}

#pragma mark - Replace Current View To Product View

- (void)replaceViewWithCurrentView:(NSString *)actionInfo productImageValue:(int)pIV andProductId:(int)itemIde {
    ProductDataIMViewController *pDIMVC = [[ProductDataIMViewController alloc] initWithNibName:@"ProductDataIMViewController" bundle:nil];
    pDIMVC.senderInfo = actionInfo;
    pDIMVC.itemIdentity = itemIde;
    float frameWidth = [pDIMVC view].frame.size.width;
    float frameHeight = [pDIMVC view].frame.size.height;
    [[pDIMVC view] setFrame:CGRectMake(0, 0, frameWidth, frameHeight)];
    [self.view.superview replaceSubview:self.view with:pDIMVC.view];
}

How can I fix this problem?

user1838670
  • 81
  • 10
  • Is `replaceViewWithCurrentView:` actually being executed? Is `pDIMVC` non-nil? Do you see anything at all happen when you press the button? – Phillip Mills Dec 24 '12 at 12:53
  • @PhillipMills ya all the code will be executed. but the xib view will not be displayed.. – user1838670 Dec 24 '12 at 13:42
  • @PhillipMills I'm using the custom view on which i am displaying it.. – user1838670 Dec 24 '12 at 13:43
  • I'd try logging everything important just before calling `replaceSubview:` and see if there are clues. Something like: `NSLog(@"Controller: %@, New View: %@, Superview: %@", pDIMVC, pDIMVC.view, self.view.superview);`. (Another consideration is, if you have Auto Layout turned on for your xib files, it might be messing with your frame adjustments.) – Phillip Mills Dec 24 '12 at 14:01

0 Answers0