我想实现用于将数据包从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=--& v=--& UISlider:0x185b6b90.midY == + 190>",
"<NSAutoresizingMaskLayoutConstraint:0x185af410 h=--& v=--& 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 && _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 && 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];
}