adding subview of another class
iv created a class with xib so i can access it throughout my app. The class basically holds a nib with has three uiviews and a few buttons buttons+labels. Now im calling class A (the one with 3 view etc) from classB but every time i addsubview to self.vie开发者_运维知识库w nothing happens. any help appreciated.
ive done the following in class B.h
#import "PlayResultViewController.h"
PlayResultViewController *playResultViewController;
in classB.m
//viewdidload
playResultViewController = [[PlayResultViewController alloc]init];
//some random method
[placeholderView addSubview:playResultViewController.loseView];
You are missing the initWithNibName to start with, here are some examples
With a Navigation controller u can use
BViewController *bController = [[BViewController alloc] initWithNibName:@"BViewController" bundle:nil];
[self.navigationController pushViewController:bController animated:YES];
[bController release];
without UInavigation controller you can test with
BViewController *bController = [[BViewController alloc] initWithNibName:@"BViewController" bundle:nil];
self.view = bController;
// or alternatively self.view = bController.view;
[bController release];
You need to tell it which nib to load....
playResultViewController = [[PlayResultViewController alloc] initWithNibName:@"Mynib" bundle:nil];
精彩评论