Nug*_*get 12 iphone xcode interface-builder uiviewcontroller ios
我对IOS的发展很陌生,我在这里面临一个我以前没有遇到过的问题.这就是我所拥有的:
我创建了一个项目,添加了一些附加到自己的类的ViewControllers.但现在,我刚在故事板中添加了一个新的ViewController.然后我创建了一个新的Objective-C类(带有UIViewController的子类).问题是在IB中,我无法将ViewController链接到新创建的类,因为我根本没有IB提供的列表中的类(请参见下图).我的新课程被调用MapShownViewController,但正如您在图像上看到的那样,它不可用.

它适用于我所有其他课程,但不适用于此课程.
这是MapShownViewController.h:
#import <UIKit/UIKit.h>
@interface MapShownViewController : UIViewController
@end
Run Code Online (Sandbox Code Playgroud)
和MapShownViewController.m:
#import "MapShownViewController.h"
@interface MapShownViewController ()
@end
@implementation MapShownViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
Run Code Online (Sandbox Code Playgroud)
有人可以解释一下我做错了吗?
小智 26
我有这个确切的问题,它让我疯了.我在从4.1升级XCode到4.4后首先注意到它.我有一个现有的项目,我一直在使用旧版本的XCode,我继续在4.4中进行工作.我完成了你所做的,并在故事板中创建了一个新的View,然后创建了子类文件,但是这个类在IB的Custom Class下拉列表中是不可用的.经过大量的谷歌搜索和挫折后,我采取了退出Xcode(完全退出,而不仅仅是关闭),然后重新启动它.然后好像通过魔术一起开始工作,新的课程在IB自定义课程下拉列表中可用.
Mik*_*sky 16
遇到同样的问题,重启XCode没有任何帮助.您可以随时右键单击故事板并选择Open As > Source Code.在XML文件中查找视图控制器元素并添加customClass属性:
<viewController title="Login" id="TJH-Bg-q4u" customClass="XYZLoginViewController" sceneMemberID="viewController">
...
</viewController>
Run Code Online (Sandbox Code Playgroud)
手动覆盖FTW :).
| 归档时间: |
|
| 查看次数: |
11073 次 |
| 最近记录: |