当前位置: 首页 > 知识库问答 >
问题:

从Xcode启动iOS模拟器并获得黑屏,随后Xcode挂起并无法停止任务

松德曜
2023-03-14

我在iOS模拟器中运行我的基本iPhone应用程序(同时通过斯坦福iTunes CS193p讲座)遇到了麻烦。

我已经搜索了一段时间(谷歌和其他),但无法找到一个解决方案到目前为止。有很多类似的bug,但是解决方案似乎并没有修复这个问题。

在Xcode中,我单击“Run”。它编译和构建成功,启动iOS模拟器,但它从来没有加载应用程序。只有顶部的状态栏。带着黑屏。

我只写了非常基本的代码(跟着讲课),无法解决这个问题。

为了更好地混淆问题,在这些讲座之前,我编写了一个web包装器(UIWebView),它工作得很好。但代码几乎没有任何区别。我从头开始创建的所有新应用程序都因同样的黑屏问题而失败。

这就好像Xcode已经失去了与iOS模拟器对话的能力,并假设它正在运行(即使我退出了iOS模拟器)。我尝试退出Xcode,它要求我停止任务。然后它就挂了。所以我必须强制重启才能退出Xcode。

我使用的是:OSX 10.8.2 Xcode 4.5.2 iOS模拟器6.0

CalculatorAppDelegate.h

#import <UIKit/UIKit.h>

@interface CalculatorAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end
#import "CalculatorAppDelegate.h"

@implementation CalculatorAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions (NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
#import <UIKit/UIKit.h>

@interface CalculatorViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *display;

@end

计算器ViewController.m

#import "CalculatorViewController.h"

@implementation CalculatorViewController

@synthesize display = _display;

- (IBAction)digitPressed:(UIButton *)sender
{
    NSString *digit = [sender currentTitle];
NSLog(@"digit pressed = %@", digit);
}

@end

共有1个答案

袁俊弼
2023-03-14

令人惊讶的是,对我起作用的是去iOS模拟器菜单,按下“重置内容和设置”。(在iOS 13中,its under Hardware)

 类似资料:
  • 我用的是Xcode 10。没有足够的空间更新到最新的Xcode。所以从苹果网站下载了它,并删除了旧的Xcode。为了腾出更多空间,我删除了所有的缓存、不可用的模拟器、派生数据和不需要的东西。之后安装了新的Xcode 11.3。 我的应用程序已成功构建。但模拟器只显示黑屏。 我试过了 “删除所有内容和设置” 而且还 默认写com。苹果核心模拟器。IndigoFramebufferServices帧缓

  • 试 卸载然后重新安装Xcode 重置内容 问题 我启动我的应用程序并运行,我知道这个cos我在控制台中看到print()的日志输出。但是,模拟器屏幕是空白的,只是黑色的。根本没有用户界面。我可以消除我的应用程序是问题,因为当我按下(模拟按下)主页时,它应该向我显示跳板,但它是空白的(黑屏)。我重置了内容 有人能帮忙吗? 附加: 我已经完全删除了Xcode,从Mac上删除了它的所有痕迹。然后重新安装

  • 我知道之前有很多人问过这个问题。但我觉得我的情况不同。在我的例子中,Xcode 9.2已经安装,我将macOS从10.13.2升级到了10.13.5。然后我安装了Xcode 10测试版。现在,当我在Xcode 9.2上运行任何项目并尝试使用模拟器时,它会变成黑色,尽管我可以看到Xcode 已卸载的Xcode 10 Beta版 卸载 现在我现在该怎么办?

  • 我使用Xcode6.4,我的应用刺激器成功构建,然后启动屏幕,然后一个黑屏出现,它是堆栈。我尝试了不同的项目,同样的事情出现黑屏再次,但没有错误。

  • 当我尝试在iOS 8.0模拟器上使用Xcode 6 Beta 4运行我的应用程序时,总是会出现以下错误: 无法启动iOS模拟器 事实上,我在这个网站上发现了一些类似的问题,我尝试了所有的答案,但仍然无法解决。我在Xcode 6的Beta 2版本中也遇到了同样的错误,所以我决定等待。但现在这已经不正常了。有人找到了发生这种情况的原因并找到了解决方案吗?

  • 我在mac book pro上,新安装的优胜美地。它大约有两年的历史,我刚刚安装了Xcode。我打开了一个全新的项目,并运行了它,但我得到的只是一个巨大的黑屏,这需要很长时间才能加载。当它这样做时,它会跳入Iphone的正常菜单部分,应用程序无法运行! 我刚刚深入研究了iOS开发。