【问题标题】:xcode iOS simulator not showing app but xcode says no errorsxcode iOS模拟器没有显示应用程序但xcode说没有错误
【发布时间】:2013-12-06 09:06:38
【问题描述】:

我正在尝试运行我的简单应用程序,该应用程序在偏航俯仰和滚动方面显示默认方向和相对于磁北的方向。 Xcode 代码说它是一个成功的构建,但是当我进入模拟器时,它会自动将我返回到 Xcode 上的这个屏幕。

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

//
//  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

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

【问题讨论】:

  • 禁用断点。

标签: ios objective-c xcode ios-simulator


【解决方案1】:

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

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

【讨论】:

  • 是的!就是这样,谢谢。我不知道断点会这样做,也不知道断点是什么。
猜你喜欢
  • 1970-01-01
  • 2023-03-20
  • 2016-03-23
  • 1970-01-01
  • 2018-01-04
  • 1970-01-01
  • 1970-01-01
  • 2012-03-08
  • 1970-01-01
相关资源
最近更新 更多