开发者

adding subview of another class

开发者 https://www.devze.com 2023-03-14 13:21 出处:网络
iv created a class with xib so i can access it throughoutmy 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 et

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];
0

精彩评论

暂无评论...
验证码 换一张
取 消