rod*_*ves 90 iphone xcode objective-c ios xcode5
I am using Xcode 5 in a newly created app and when I just create it I go for the run button e click on it, then the project gets built but it does not show in the iOS Simulator and I get the following message:
Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' -
perhaps the designated entry point is not set?
Run Code Online (Sandbox Code Playgroud)
I've Googled about it of course and everybody points out that this is happening because XCode does not know yet which view controller is the initial one. But the weird thing is that I created the app as a page based (also tried single-view and tabbed app options) app and XCode already had defined a Storyboard for it.
Also, when I go to the main interface option of the project the storyboard (named "Main" by Xcode itself) is set, and in the Storyboard, my view controller is set as the "Initial View Controller"
What is wrong?
小智 55
So this also happened to me too. I checked 50 times and my "Is Initial View Controller" was checked, believe me. It happened out of the blue. So how did I fix it?
And*_*ndy 39
首先单击右侧Utilities栏中的View Controller .接下来选择Attributes Inspector并确保在View Controller部分下选中'Is Initial View Controller'复选框!
Jay*_*bey 14
使用Interface Builder:
检查是否设置了" 是否为初始视图控制器 ".您可以使用以下步骤进行设置:
如果您已完成此步骤并仍然收到错误 uncheck and do it again.
以编程方式使用:
Objective-C:
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"]; // <storyboard id>
self.window.rootViewController = viewController;
[self.window makeKeyAndVisible];
return YES;
Run Code Online (Sandbox Code Playgroud)
斯威夫特:
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
var objMainViewController: MainViewController = mainStoryboard.instantiateViewControllerWithIdentifier("MainController") as! MainViewController
self.window?.rootViewController = objMainViewController
self.window?.makeKeyAndVisible()
return true
Run Code Online (Sandbox Code Playgroud)
sup*_*org 14
如果您有一些代码,也会报告此警告:
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window?.rootViewController = myAwesomeRootViewController
window?.makeKeyAndVisible()
Run Code Online (Sandbox Code Playgroud)
在这种情况下,请转到目标设置的第一页并设置Main Interface
为空,因为您不需要应用的故事板条目.
Sha*_* TK 10
Setup the window manually,
- (void)applicationDidBecomeActive:(UIApplication *)application
{
if (!application.keyWindow.rootViewController)
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *myViewController= [storyboard instantiateViewControllerWithIdentifier:@"myViewController identifier"];
application.keyWindow.rootViewController = myViewController;
}
}
Run Code Online (Sandbox Code Playgroud)
我已经体验过这一点,我的标签栏控制器没有出现在模拟器中,还有黑屏.为了让我的应用程序出现在模拟器中,我执行了以下操作.
Is Initial View Controller
属性"检查器选项卡下的.当我改变了故事板文件名为"我得到这个错误Main.storyboard " TO:" XXX.storyboard "
我的解决方案是:
祝好运
归档时间: |
|
查看次数: |
108514 次 |
最近记录: |