XcodeからiOSシミュレータを起動すると黒い画面が表示され、その後Xcodeがハングしてタスクを停止できなくなります。質問する

XcodeからiOSシミュレータを起動すると黒い画面が表示され、その後Xcodeがハングしてタスクを停止できなくなります。質問する

スタンフォード大学の iTunes CS193p 講義を受講中に、iOS シミュレーターで基本的な iPhone アプリケーションを実行する際に問題が発生しています。

しばらく検索していますが (Google と SO の両方で)、今のところ解決策が見つかりません。同様のバグは多数ありますが、解決策ではこの問題が解決されないようです。

Xcode で「実行」をクリックします。コンパイルとビルドは正常に行われ、iOS シミュレーターは起動しますが、アプリの読み込みに至りません。上部のステータス バーのみが表示されます。画面は黒くなります。

私は(講義に沿って)非常に基本的なコードしか書いていませんが、この問題を解決できません。

さらに混乱を招くのは、(UIWebView)これらの講義の前に Web ラッパーを作成したのですが、これは問題なく動作しているということです。しかし、コードにはほとんど違いがありません。ゼロから作成した新しいアプリはすべて、同じ黒い画面の問題で失敗します。

シミュレーターのホームボタンを押してアプリを起動すると、表示されます。しかし、Xcode は何が起こっているのか認識していないようです。

Xcode が iOS シミュレータと通信する能力を失い、iOS シミュレータが実行中であると想定しているかのようです (iOS シミュレータを終了しても)。Xcode を終了しようとすると、タスクを停止するように求められます。その後、ハングアップします。そのため、Xcode を終了するには強制的に再起動する必要があります。

使用しているのは: OSX 10.8.2 Xcode 4.5.2 iOS シミュレータ 6.0

計算機アプリデリゲート.h

#import <UIKit/UIKit.h>

@interface CalculatorAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end

計算機アプリデリゲート.m

#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

計算機ビューコントローラ.h

#import <UIKit/UIKit.h>

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

@end

計算機ビューコントローラ.m

#import "CalculatorViewController.h"

@implementation CalculatorViewController

@synthesize display = _display;

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

@end

ベストアンサー1

驚いたことに、iOS シミュレータ メニューに移動して、「コンテンツと設定をリセット」を押すとうまくいきました。(iOS 13 では、ハードウェアの下にあります)

おすすめ記事