xcode iOS模拟器没有显示应用程序,但xcode说没有错误

时间:2013-11-21 18:10:10

标签: ios objective-c xcode ios-simulator

我试图运行我的简单应用程序,它显示默认方向和相对于磁北方的方向,包括偏航俯仰和滚转。 Xcode代码说它是一个成功的构建,但是当我去模拟器时它会自动将我返回到Xcode上的这个屏幕。 enter image description here

模拟器只是一个黑屏。 Heres是我的所有代码,它不仅仅是一个实现文件:

//
//  ViewController.m
//  gyro_test
//
//  Created by USER on 11/20/13.
//  Copyright (c) 2013 taphappytech. All rights reserved.
//

#import <CoreMotion/CoreMotion.h>
#import "ViewController.h"

@interface ViewController (){

}
@property(nonatomic, strong) CMMotionManager *motionManager;

@end

@implementation ViewController

@synthesize motionManager;

@synthesize navPitch;
@synthesize navRoll;
@synthesize navYaw;

@synthesize magPitch;
@synthesize magRoll;
@synthesize magYaw;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    motionManager = [[CMMotionManager alloc] init];
    //Start up the CMMotionManager


    motionManager.deviceMotionUpdateInterval = 1.0 / 60.0;
    //Set the update interval to 60Hz

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)natOrientation:(id)sender {

    [motionManager startDeviceMotionUpdates];

    double rRotation = motionManager.deviceMotion.attitude.roll*180/M_PI;
    double pRotation = motionManager.deviceMotion.attitude.pitch*180/M_PI;
    double yRotation = motionManager.deviceMotion.attitude.yaw*180/M_PI;

    NSString *myString = [NSString stringWithFormat:@"%f",yRotation];
    self.navYaw.text = myString;

    myString = [NSString stringWithFormat:@"%f",pRotation];
    self.navPitch.text = myString;

    myString = [NSString stringWithFormat:@"%f",rRotation];
    self.navRoll.text = myString;

}

- (IBAction)magOrientation:(id)sender {

    NSOperationQueue *currentQueue = [NSOperationQueue currentQueue];

    [self.motionManager     startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXMagneticNorthZVertical     toQueue:currentQueue withHandler:^(CMDeviceMotion *motion, NSError *error)     {NSLog(@"%@",motion.attitude);}];


    double rRotation = motionManager.deviceMotion.attitude.roll*180/M_PI;
    double pRotation = motionManager.deviceMotion.attitude.pitch*180/M_PI;
    double yRotation = motionManager.deviceMotion.attitude.yaw*180/M_PI;

    NSString *myString = [NSString stringWithFormat:@"%f",yRotation];
    self.magYaw.text = myString;

    myString = [NSString stringWithFormat:@"%f",pRotation];
    self.magPitch.text = myString;

    myString = [NSString stringWithFormat:@"%f",rRotation];
    self.magRoll.text = myString;

}
@end

为什么这个应用程序没有出现在模拟器上?

1 个答案:

答案 0 :(得分:2)

您在Xcode中启用了断点。点击突出显示的代码行左侧的小蓝条,然后重新运行您的应用。

断点会导致您的应用“暂停” - 以便可以更轻松地调试代码。由于此代码在启动时运行,因此断点会在加载视图之前暂停您的应用程序。