0

iv 使用 xib 创建了一个类,因此我可以在整个应用程序中访问它。该类基本上拥有一个具有三个 uiview 和几个按钮按钮+标签的笔尖。现在我从 classB 调用 A 类(具有 3 个视图等),但每次我将 subview 添加到 self.view 时都没有任何反应。任何帮助表示赞赏。

我在 Bh 课上做了以下事情

#import "PlayResultViewController.h"
PlayResultViewController *playResultViewController;

在 B.m 班

//viewdidload
playResultViewController = [[PlayResultViewController alloc]init];
//some random method
[placeholderView addSubview:playResultViewController.loseView];
4

2 回答 2

0

你需要告诉它要加载哪个笔尖....

playResultViewController = [[PlayResultViewController alloc] initWithNibName:@"Mynib" bundle:nil];
于 2011-06-21T08:12:36.753 回答
0

您缺少 initWithNibName 开头,这里有一些示例

使用导航控制器,您可以使用

BViewController *bController = [[BViewController alloc] initWithNibName:@"BViewController" bundle:nil];
[self.navigationController pushViewController:bController animated:YES];
[bController release];

没有 UInavigation 控制器,您可以使用它进行测试

BViewController *bController = [[BViewController alloc] initWithNibName:@"BViewController" bundle:nil];
    self.view = bController; 
    // or alternatively self.view = bController.view;
    [bController release];
于 2011-06-21T08:15:39.370 回答