2013-11-21 2 views
-2

Im пытается запустить мое простое приложение, которое отображает ориентацию по умолчанию и ориентацию относительно магнитного севера как с точки зрения высоты, так и рулона. Код Xcode говорит о его успешной сборке, но когда я иду на симулятор, он автоматически возвращает меня на этот экран на Xcode. enter image description herexcode iOS симулятор не показывает приложение, но xcode говорит, что нет ошибок

Симулятор - это просто черный экран. 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

Отключить контрольную точку. – rmaddy

+0

ha wow спасибо maddy. – ian

ответ

2

У вас есть точка останова, включенная в Xcode. Нажмите маленькую синюю полосу слева от выделенной строки кода, а затем запустите приложение.

Точки останова заставляют ваше приложение «приостанавливаться» - так что код можно более легко отладить. Поскольку этот код запускается при запуске, точка останова приостанавливает ваше приложение, прежде чем оно даже загрузит представление.

+0

Да! это было спасибо. Я понятия не имел, что точка останова будет делать это или что точка останова в этом отношении. – ian

Смежные вопросы