Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 添加视差图像后未调用方法_Ios_Objective C_Xcode_Methods_Delegates - Fatal编程技术网

Ios 添加视差图像后未调用方法

Ios 添加视差图像后未调用方法,ios,objective-c,xcode,methods,delegates,Ios,Objective C,Xcode,Methods,Delegates,因此,我最近在我的应用程序中实现了视差图像,效果非常好,但这打破了一个调用方法的按钮 以下是我的故事板的图片: 这是我的.h代码: @interface _01FirstViewController : UIViewController <UITextFieldDelegate, UIAccelerometerDelegate>{ UIAccelerometer *accelerometer; float xoof; float yoff; float xvelocity; flo

因此,我最近在我的应用程序中实现了视差图像,效果非常好,但这打破了一个调用方法的按钮

以下是我的故事板的图片:

这是我的.h代码:

@interface _01FirstViewController : UIViewController <UITextFieldDelegate, UIAccelerometerDelegate>{

UIAccelerometer *accelerometer;
float xoof;
float yoff;
float xvelocity;
float yvelocity;
float xaccel;
float yaccel;
}

@property (nonatomic, retain) UIAccelerometer *accelerometer;
@property (weak, nonatomic) IBOutlet UIScrollView *BGScrollView;
@property (weak, nonatomic) IBOutlet UIButton *Track;
@property (weak, nonatomic) IBOutlet UITextField *trackingNumber;
@property (strong, nonatomic) NSDictionary *posts;
@property (strong,nonatomic) NSString *TrackPoint;
@property (strong,nonatomic) NSArray *Path;
@property (strong,nonatomic) NSString *documentFolder;
@property (strong,nonatomic) NSString *filePath;

-(void)parseTrackNo;
-(void)reloadTrackingNumber;
这是已停止调用该方法的按钮:

- (IBAction)Track:(id)sender {
[self parseTrackNo]; //Not calling method
NSLog(@"Button Pressed"); //This gets logged correctly

}
我已尝试删除所有代码更改,因此我怀疑这与按钮嵌套在情节提要视图中或代理更改有关

有人能给我指出正确的方向吗

按要求编辑ParseTracking的代码。注意,在视差发生变化之前,此操作一直工作正常:

-(void)parseTrackNo
{

    _01AppDelegate *appDelegate = (_01AppDelegate *)[[UIApplication sharedApplication] delegate];

    //Get Tracking Number from textField
    appDelegate.TrackingNumber = _trackingNumber.text;

    //Check String isn't empty
    if ([_trackingNumber.text  isEqual: @""]){

    } else{

        //Check against Royal Mail API
        NSString *trackingURL = [NSString stringWithFormat:@"%@%@",   @"http://api.e44.co/tracktrace/", appDelegate.TrackingNumber];

        NSURL *royalMail = [NSURL URLWithString:trackingURL];

        //Return results
        NSData *royalMailResults = [NSData dataWithContentsOfURL:royalMail];

        //Parse JSON results
        if(royalMailResults != nil)
        {
            NSError *error = nil;
            id result = [NSJSONSerialization JSONObjectWithData:royalMailResults options:NSJSONReadingMutableContainers error:&error];
            if (error == nil)

            //Convert to dictionary/array
            self.posts = (NSDictionary *)result;
            NSArray *trackRecords = _posts[@"trackRecords"];

            //Return keys from posts (Dict)
            NSString *response = [self.posts valueForKeyPath:@"response"];
            NSLog(@"Response: %@", response);

            NSString *returnedTrackingNumber = [self.posts valueForKeyPath:@"trackingNumber"];
            NSLog(@"Returned tracking number: %@", returnedTrackingNumber);

            NSString *delivered = [self.posts valueForKeyPath:@"delivered"];
            NSLog(@"delivered: %@", delivered);

            NSString *signature = [self.posts valueForKeyPath:@"signature"];
            NSLog(@"Signature: %@", signature);


            //Track Records
            NSString *Date = [trackRecords valueForKeyPath:@"date"];
            NSLog(@"date: %@", Date);

            NSString *Time = [trackRecords valueForKeyPath:@"time"];
            NSLog(@"time: %@", Time);

            NSString *Status = [trackRecords valueForKeyPath:@"status"];
            NSLog(@"status: %@", Status);

            appDelegate.LocationData = [[trackRecords valueForKey:@"trackPoint"] componentsJoinedByString:@""];
            NSLog(@"GeoLocation: %@", appDelegate.LocationData);


            //Check for Errors returned
            if ([self.posts objectForKey:@"errorMsg"]) {
                NSLog(@"ERROR MOTHERFUCKER");
                UIAlertView *alert = [[UIAlertView alloc]

                initWithTitle:@"Error"
                message:@"It appears that you have entered an incorrect tracking number"
                delegate:self
                cancelButtonTitle:@"OK"
                otherButtonTitles:nil, nil];
                [alert show];
            } else {
                [self performSegueWithIdentifier:@"addPackageSegue" sender:self];
            }
        }

    }
}

你能发布你的parseTrackNo函数的代码吗?添加了parseTrackNo函数:谢谢。您是否在parseTrackNo函数的第一行中放置了NSLog?如果不是,您如何确定不再调用该函数?另外,你有没有试着去除视差以确保这是光源?np。没有任何NSLog,例如:NSLog@Response:%@,响应;没有人打电话。我已经删除了所有代码更改,但没有任何改进,但是我认为问题与在故事板中嵌套按钮有关。所有日志都在else语句中,因此如果[\u trackingNumber.text isEqual:@]为真,则所有日志都不会输出。试着在那条线前放一根圆木。
-(void)parseTrackNo
{

    _01AppDelegate *appDelegate = (_01AppDelegate *)[[UIApplication sharedApplication] delegate];

    //Get Tracking Number from textField
    appDelegate.TrackingNumber = _trackingNumber.text;

    //Check String isn't empty
    if ([_trackingNumber.text  isEqual: @""]){

    } else{

        //Check against Royal Mail API
        NSString *trackingURL = [NSString stringWithFormat:@"%@%@",   @"http://api.e44.co/tracktrace/", appDelegate.TrackingNumber];

        NSURL *royalMail = [NSURL URLWithString:trackingURL];

        //Return results
        NSData *royalMailResults = [NSData dataWithContentsOfURL:royalMail];

        //Parse JSON results
        if(royalMailResults != nil)
        {
            NSError *error = nil;
            id result = [NSJSONSerialization JSONObjectWithData:royalMailResults options:NSJSONReadingMutableContainers error:&error];
            if (error == nil)

            //Convert to dictionary/array
            self.posts = (NSDictionary *)result;
            NSArray *trackRecords = _posts[@"trackRecords"];

            //Return keys from posts (Dict)
            NSString *response = [self.posts valueForKeyPath:@"response"];
            NSLog(@"Response: %@", response);

            NSString *returnedTrackingNumber = [self.posts valueForKeyPath:@"trackingNumber"];
            NSLog(@"Returned tracking number: %@", returnedTrackingNumber);

            NSString *delivered = [self.posts valueForKeyPath:@"delivered"];
            NSLog(@"delivered: %@", delivered);

            NSString *signature = [self.posts valueForKeyPath:@"signature"];
            NSLog(@"Signature: %@", signature);


            //Track Records
            NSString *Date = [trackRecords valueForKeyPath:@"date"];
            NSLog(@"date: %@", Date);

            NSString *Time = [trackRecords valueForKeyPath:@"time"];
            NSLog(@"time: %@", Time);

            NSString *Status = [trackRecords valueForKeyPath:@"status"];
            NSLog(@"status: %@", Status);

            appDelegate.LocationData = [[trackRecords valueForKey:@"trackPoint"] componentsJoinedByString:@""];
            NSLog(@"GeoLocation: %@", appDelegate.LocationData);


            //Check for Errors returned
            if ([self.posts objectForKey:@"errorMsg"]) {
                NSLog(@"ERROR MOTHERFUCKER");
                UIAlertView *alert = [[UIAlertView alloc]

                initWithTitle:@"Error"
                message:@"It appears that you have entered an incorrect tracking number"
                delegate:self
                cancelButtonTitle:@"OK"
                otherButtonTitles:nil, nil];
                [alert show];
            } else {
                [self performSegueWithIdentifier:@"addPackageSegue" sender:self];
            }
        }

    }
}