首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >与NSViewController交换

与NSViewController交换
EN

Stack Overflow用户
提问于 2014-08-02 06:17:48
回答 2查看 316关注 0票数 0

我正在尝试在Windows中交换两个视图。我使用Cocoa (仅用于Mac)和Xcode 5.1.1以及NSViewController来获取它。所有的编译都很完美,但这不起作用,我从编译器那里得到了下一条消息:

Libdyld.dylib 0x00007fff866995fd start +1

这是我的Xcode项目

.h文件

代码语言:javascript
复制
#import "Cocoa/Cocoa.h"
#import "PrimaryViewController.h" //My views
#import "SecondViewController.h"

@interface
AppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;

@property (weak) IBOutlet NSView *myCustomView;
@property (strong) IBOutlet NSViewController *myViewController;

-(IBAction)button1Clicked:(id)sender;
-(IBAction)button2Clicked:(id)sender;

@end

.m

代码语言:javascript
复制
#import "AppDelegate.h"
@implementation AppDelegate

//@synthesize myCustomView = _myCustomView;<br/>
//@synthesize myViewController = _myViewController;<br/>

-(IBAction)button1Clicked:(id)sender {
    NSLog(@"Clicked on the first button");
    [[_myViewController view ]removeFromSuperview];
    _myViewController = [[PrimaryViewController alloc] initWithNibName:@"PrimaryView­Controller" bundle:nil];
    [_myCustomView addSubview:[_myViewController view]];
    [[_myViewController view] setFrame:[_myCustomView bounds]];
}

-(IBAction)button2Clicked:(id)sender {
    NSLog(@"Clicked on the second button");
    [[_myViewController view] removeFromSuperview];
    _myViewController = [[SecondViewController alloc]initWithNibName:@"SecondaryView­Controller" bundle:nil];
    [_myCustomView addSubview:[_myViewController view]];
    [[_myViewController view]setFrame:[_myCustomView bounds]];
}

@end

你能帮帮我吗?

EN

回答 2

Stack Overflow用户

发布于 2014-08-02 13:03:26

SecondaryViewController.xib中,您将文件所有者命名为SecondViewController。将其更改为SecondaryViewController,它应该可以工作。

票数 0
EN

Stack Overflow用户

发布于 2014-08-02 15:12:52

是的,当我创建第二个“视图”时,我创建了一个文件:SecondViewController.xib、SecdViewController.h和SecdViewController.m。

因此,当我创建它的一个实例时,在initWithNibName中的“initWithNibName”方法中

我把它叫做“SecondaryViewController”(vs @"SecondViewController")。

我删除了SecondaryViewController并修改了它,因为SecondViewController和所有的功能都很完美,谢谢@TheAmateurProgrammerless ;)

在这里,我的项目修复了它

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25092272

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档