IOS не удалось передать результирующий набор из ViewController в другой

#ios #objective-c #uiview #protocols

#iOS #objective-c #uiview #протоколы

Вопрос:

Я хотел бы реализовать модуль для передачи пакета данных из SliderViewController в другой. Когда дело доходит до выполнения, отображается следующее сообщение консоли:

Я понятия не имею, что происходит для успешной передачи данных, даже какая строка кода вызывает эту проблему

 Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2014-06-25 17:01:20.471 marker[3008:60b] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSIBPrototypingLayoutConstraint:0x185bc390 'IB auto generated at build time for view with fixed frame' V:|-(175)-[UISlider:0x185b6b90]   (Names: '|':UIView:0x185b7960 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x18345f00 h=--amp; v=--amp; UISlider:0x185b6b90.midY ==   190>",
    "<NSAutoresizingMaskLayoutConstraint:0x185af410 h=--amp; v=--amp; V:[UISlider:0x185b6b90(176)]>"
)

Will attempt to recover by breaking constraint 
<NSIBPrototypingLayoutConstraint:0x185bc390 'IB auto generated at build time for view with fixed frame' V:|-(175)-[UISlider:0x185b6b90]   (Names: '|':UIView:0x185b7960 )>

Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
  

Ниже приведена моя работа:

Оригинальный ViewController:

 #pragma mark - Protocol Methods

-(void)setVerticalName:(float)firstName {

    _verticalSliderValue = firstName;
}

-(void)setCircleName:(float)lastName {

    _circleSliderValue = lastName;
}




-(void) mapView:(GMSMapView *)mapView didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate{

    sliderVC = [self.storyboard instantiateViewControllerWithIdentifier:@"SliderViewController"];
    sliderVC.view.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.1];
    self.modalPresentationStyle = UIModalPresentationCurrentContext;
    [self presentViewController:sliderVC animated:YES completion:NULL];

    [sliderVC setDelegate:self];

    if(_verticalSliderValue!=0 amp;amp; _circleSliderValue!=0){
        CheckPoints *myCar=[[CheckPoints alloc] init];
        [myCar setState:0];
        [myCar setLatitude:coordinate.latitude];
        [myCar setLongitude:coordinate.longitude];
        NSString* theTextValue = @"Desitnation";
        [myCar setDesp:theTextValue];

        [array addObject:myCar];
        CheckPoints *lastChk = array.lastObject;
        [self writeToTextFile:[NSString stringWithFormat:@"%@%@%@%@%@%@", lastChk.getDesp , @"n",[NSString stringWithFormat:@"%f", lastChk.getLatitude],
                               @"n", [NSString stringWithFormat:@"%f", lastChk.getLongitude], @"n" ]];
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        [defaults setFloat:lastChk.getLatitude forKey:@"lati"];
        [defaults setFloat:lastChk.getLongitude forKey:@"longi"];
        [defaults setObject:lastChk.getDesp forKey:@"desp"];
        [defaults synchronize];

        for (int i = 0; i < [array count]; i  ) {
            CheckPoints *current =  [array objectAtIndex:i];
            if(current.getLatitude != lastChk.getLatitude amp;amp; current.getLongitude != lastChk.getLongitude){
                [current setState:1];
                NSString* previousTitle = [NSString stringWithFormat:@"%@%@", @"Checkpoint" ,[NSString stringWithFormat:@"%i", i 1]];
                [current setDesp:previousTitle];
            }
        }
        [self addMarkers];
    }
  

SliderViewCOntroller.h

 //

#import <UIKit/UIKit.h>
#import "EFCircularSlider.h"

@protocol passValues <NSObject>

-(void)setVerticalName:(float)firstName;
-(void)setCircleName:(float)lastName;

@end


@interface SliderViewController : UIViewController
@property (strong, nonatomic) IBOutlet UILabel *uiValue;
@property (strong, nonatomic) IBOutlet UISlider *uiSlider;
@property (strong, nonatomic) IBOutlet UIButton *btnReset;
@property (strong, nonatomic) IBOutlet UILabel *uiValue2;
@property (strong, nonatomic)  EFCircularSlider* circularSlider;
@property (nonatomic) float verticalSliderValue;
@property (nonatomic) float circleSliderValue;
@property (retain)id <passValues> delegate;


- (IBAction)reset:(id)sender;
- (IBAction)sliderChange:(id)sender;


@end
  

SliderViewController.m:

 - (IBAction)reset:(id)sender {
    [self writeToTextFile:valueV :valueC];
    self.uiValue.text =[NSString stringWithFormat:@"%.2f" , 0.00];
    [self.uiSlider setValue:0.00];
    self.uiValue2.text =[NSString stringWithFormat:@"%.2f" , 0.00];
    [_circularSlider setCurrentValue:0.0f];
  //  UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
   // ViewController *fc = (ViewController*)[UIStoryboard instantiateViewControllerWithIdentifier:@"FormView"];


    [[self delegate]setVerticalName:_verticalSliderValue];

    [[self delegate]setCircleName:_circleSliderValue];

    [self dismissViewControllerAnimated:YES completion:nil];

  }
  

Комментарии:

1. ваш журнал указывает на проблемы с автоматической компоновкой, которые не имеют ничего общего с передачей данных.

2. Вы имеете в виду, что я должен вызывать addMarkers в методе viewWillAppear ?

3. Нет. Это означает, что ваш автоматический макет имеет слишком много ограничений. Вы должны научиться использовать автоматическую компоновку или просто не использовать ее. Я предпочитаю последнее.

4. Я не понимаю. Я просто имитирую onActivityResult @ Android для передачи значений между ViewControllers. Никогда не привязывался к автоматическим макетам в отношении моей работы

5. подождите…. какой Android? разве вы не работаете над проектом iOS?