我正在使用Xcode 4,当我运行我的应用程序时,第一个屏幕无法加载.它在模拟器和设备上失败.我已经搜索了答案,他们都说要确保我已经将文件所有者中的圈子拖到了正确的视图中.对不起,我不记得事情的名字,我是Xcode的新手.我把圆圈拖到正确的视图并尝试了很多东西,但没有一个能够工作.我能做错什么?
这是完整的错误:
2012-02-19 12:59:54.655 Ponyboard[271:207]
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "PonyboardViewController" nib but the view outlet was not set.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00f095a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0105d313 objc_exception_throw + 44
2 CoreFoundation 0x00ec1ef8 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x00ec1e6a +[NSException raise:format:] + 58
4 UIKit 0x0020d709 -[UIViewController _loadViewFromNibNamed:bundle:] + 295
5 UIKit 0x0020b134 -[UIViewController loadView] + 120
6 UIKit 0x0020b00e -[UIViewController view] …Run Code Online (Sandbox Code Playgroud) 我在NIB文件中定义了一个自定义视图,并希望在StoryBoard中实例化一个副本,但我遇到了autolayout的问题.
在一个简单的示例中,自定义视图具有固定大小的单个标签,并且垂直和水平居中,全部使用自动布局.

文件所有者设置为我的类,它有一个顶视图的插座.在自定义视图实现中,我做:
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if(self)
{
[[NSBundle mainBundle] loadNibNamed:@"FMCompassView" owner:self options:nil];
[self addSubview:self.topView];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
现在,在我的故事板中,我添加了一个UIView,将它的类设置为我的自定义类,并将其布局为大小并居中于我的页面,再次使用autolayout.

并且我的窗口小部件的位置和大小正确,但它的内容未调整大小,如下图所示:

我尝试从NIB加载后添加更多约束,类似于:
UIView* subV = self.topView;
NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(subV);
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[subV]|" options:NSLayoutFormatAlignAllBaseline metrics:nil views:viewsDictionary]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[subV]|" options:NSLayoutFormatAlignAllBaseline metrics:nil views:viewsDictionary]];
Run Code Online (Sandbox Code Playgroud)
但这会导致无效的布局约束.
有关如何使其工作的任何想法?
干杯!
我打电话的时候:
self.viewController = [[DidItViewController alloc] initWithNibName:@"DidItViewController" bundle:nil];
Run Code Online (Sandbox Code Playgroud)
然后我在调试器中执行此行后立即检查self.viewController.navController,我发现它是空的(0x0).
在DidItViewController上,我将navController定义为:
IBOutlet NavigationController *navController;
Run Code Online (Sandbox Code Playgroud)
在我的nib文件中,我将NavigationController绑定到文件所有者(DidItViewController)上的这个navController属性.
为什么我的navController没有创建?有任何想法吗?我想我可能会遗漏一些关于initWithNibName工作方式的东西.
谢谢.
我想处理与一个UIViewController中和两个XIBs的iPad应用方向的变化,让我们说MenuView和MenuViewLandscape.
所以,在MenuViewController的willRotateToInterfaceOrientation方法,我怎么能更改,恕不使用其他控制器为风景模式XIB?
我正在使用以下代码:
if( toInterfaceOrientation != UIInterfaceOrientationPortrait ){
MenuViewController *landscape = [[MenuViewController alloc]
initWithNibName: @"MenuViewLandscape"
bundle:nil
];
[self setView:landscape.view];
}
else {
MenuViewController *potrait = [[MenuViewController alloc]
initWithNibName: @"MenuView"
bundle:nil
];
[self setView:potrait.view];
}
Run Code Online (Sandbox Code Playgroud)
但是当我去横向查看XIB时,横向视图控件没有正确旋转.
我们公司正在为iPad开发一个相当大的应用程序.最终,我们希望能够为每个客户(租户)甚至每个用户(该客户)自定义UI.我们从HTML5开始,但正在转向原生.
我已经完成了从服务器下载XML(甚至生成XIB/NIB文件)并动态添加到应用程序的阅读.
现在有了iOS 5(甚至还有6个),故事板正在发挥重要作用.
我的问题:
- 使用(多个?)故事板或XIB会更好吗?
- 如果我想提供动态用户界面,我有哪些选择?
我不是在寻找一个神奇的药丸,也不是关于HTML5与本机的讨论,只是关于我如何提供动态界面以及哪些技术可以帮助这样做的一些信息.
我正在尝试发布iOS应用程序,但是当我尝试验证构建时收到这些错误:
Nib file 'Main-iPad~.nib' was not found. Please ensure the specified file is included in the bundle with any required device modifiers appended to the filename
Invalid Info.plist: The Info.plist may contain either UIMainStoryboardFile or NSMainNibFile, but it must not contain both keys. For more information, refer to the Information Property List Key Reference.
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用来自github的这个预先构建的页面菜单pod中的pod在我的应用程序中实现页面菜单segue
在说明中,它说:
var controller : UIViewController = UIViewController(nibName:"controllerNibName", bundle: nil)
controller.title = "SAMPLE TITLE"
controllerArray.append(controller)
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
var chatAreaCtrl : UIViewController = ChatAreaCtrl(nibName: "ChatAreaCtrl", bundle: nil)
chatAreaCtrl.title = "Chats"
controllerArray.append(chatAreaCtrl)
Run Code Online (Sandbox Code Playgroud)
这让我错误:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: ...(loaded)' with name 'ChatAreaCtrl''
Run Code Online (Sandbox Code Playgroud)
我是编程和Swift的新手,但我想我没有指定Nib是正确的?
谢谢!
在我将Xcode更新到7.3之后,我发现当我创建UIView类或UITableViewCell时,Xcode无法创建Xib文件.有人知道原因吗?
我有一个小的xib文件UIView,它包含一些标签.现在,我正在尝试将其加载UIView到现有文件中UIViewController,并更改其中一个标签文本.我想这样做的原因是,UIView将重复使用不同的标签文本,所以我想制作一个自定义类并从xib加载它将是最好的方法.
我已经尝试了几种加载它的方法,并且我已经在我的viewcontroller上成功显示了它.问题是,一旦我尝试IBOutlet在Interface Builder中实际链接并访问它,我的应用程序崩溃了.
我创建了一个自定义UIView类,如下所示:
CoverPanel.h
@interface CoverPanel : UIView {
IBOutlet UILabel *headline;
}
@property (nonatomic, retain) IBOutlet UILabel *headline;
@end
Run Code Online (Sandbox Code Playgroud)
CoverPanel.m
@implementation CoverPanel
@synthesize headline;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
// Initialization code.
//
self = [[[NSBundle mainBundle] loadNibNamed:@"CoverPanel" owner:self options:nil] objectAtIndex:0];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
在CoverPanel.xib,我已经链接UILabel到标题出口.在我的viewcontroller中,这是我如何创建CoverPanel实例,这就是它崩溃的地方:
CoverPanel *panelView = [[CoverPanel alloc] initWithFrame:CGRectMake(0,0,300,100)];
Run Code Online (Sandbox Code Playgroud)
到现在为止还挺好.它显示与UIView.xib中的布局完全相同.但是一旦我尝试改变 …
我有一个类似的问题可可-基于视图的NSTableView的,使用在多个表中一个单元,通过放大
苹果自己的文档进行makeViewWithIdentifier:owner:
"通常,标识符与Interface Builder中的外部NIB相关联,表视图将自动使用提供的所有者实例化NIB."
这似乎意味着你应该能够NSTableCellView将nib 存储在包含nib的单独nib中NSTableView.然而,在我的实验中,我只能获得包含在tableview中的单元格,我正在调用它.即,如果我将我的单元格剪切并粘贴到新的.xib文件中,则tableview将无法再找到它.我做错了什么,或者这实际上是不可能的,我在某种程度上误读了Apple的文档?
nib ×10
ios ×5
xcode ×4
xib ×4
iphone ×3
storyboard ×2
app-store ×1
autolayout ×1
cocoa ×1
ipad ×1
landscape ×1
nstableview ×1
rotation ×1
swift ×1
uitableview ×1
uiview ×1
xcode4 ×1