objective c - iOS redirect to new ViewCOntroller does not load all UI elements -
objective c - iOS redirect to new ViewCOntroller does not load all UI elements -
i trying implement google map module set command parameters before adding marker
the wayout initiate acquire result of new viewcontroller via nsbundles. want goal redirect sameviewcontroller expected result.
but when comes implementation , loads actual result:
expected result: actual result
would please tell me other details instantiate new viewcontroller ui elements beingness set expected viewcontrollers? swear new viewcontroller has require elements beingness set on?
the actual console message writes:
2014-06-18 17:50:37.766 marker[1469:60b] text=2014-06-18 17:50:36 2014-06-18 17:50:41.102 marker[1469:60b] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: 'storyboard (<uistoryboard: 0x17daf180>) doesn't contain view controller identifier 'sliderviewcontroller'' *** first throw phone call stack: (0x3102dfd3 0x3b7dcccf 0x33d1bfb7 0x7e155 0x31031584 0x30f7c0db 0x30f7f873 0x231ffb 0x310300f1 0x30f7f7b8 0x20d6bb 0x138133 0x155319 0x339d000d 0x3387b503 0x33c22af5 0x33842373 0x33840abb 0x30ff92a5 0x30ff6c49 0x30ff6f8b 0x30f61f0f 0x30f61cf3 0x35e66663 0x338ad16d 0x7f4ed 0x3bce9ab7) libc++abi.dylib: terminating uncaught exception of type nsexception (lldb)
the below code
-(void) mapview:(gmsmapview *)mapview didlongpressatcoordinate:(cllocationcoordinate2d)coordinate{ slidervc = [self.storyboard instantiateviewcontrollerwithidentifier:@"sliderviewcontroller"]; slidervc.view.backgroundcolor = [uicolor yellowcolor]; self.modalpresentationstyle = uimodalpresentationcurrentcontext; [self presentviewcontroller:slidervc animated:yes completion:null]; }
code new viewcontroller (.m) only:
#import "sliderviewcontroller.h" #import <audiotoolbox/audioservices.h> #import "efcircularslider.h" @interface sliderviewcontroller (){ nsstring *valuev; nsstring *valuec; } @end @implementation sliderviewcontroller - (void)viewdidload { [super viewdidload]; _uislider.minimumvalue = 0.0; _uislider.maximumvalue = 100.0; [_uislider removeconstraints:_uislider.constraints]; [_uislider settranslatesautoresizingmaskintoconstraints:yes]; float value = m_pi * -0.5 ; _uislider.transform = cgaffinetransformmakerotation(value); cgrect sliderframe = cgrectmake(60, 300, 100, 100); efcircularslider* circularslider = [[efcircularslider alloc] initwithframe:sliderframe]; [circularslider addtarget:self action:@selector(valuechanged:) forcontrolevents:uicontroleventvaluechanged]; [self.view addsubview:circularslider]; [circularslider setcurrentvalue:10.0f]; // additional setup after loading view. } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } -(void)valuechanged:(efcircularslider*)slider { self.uivalue2.text = [nsstring stringwithformat:@"%.02f", slider.currentvalue ]; valuec = self.uivalue2.text; if(slider.currentvalue > 20.0 && slider.currentvalue < 30.0 ){ audioservicesplaysystemsound(1003); // audioservicesplayalertsound(ksystemsoundid_vibrate); audioservicesplaysystemsound(ksystemsoundid_vibrate); } } - (ibaction)reset:(id)sender { [self writetotextfile:valuev :valuec]; self.uivalue.text =[nsstring stringwithformat:@"%.2f" , 0.00]; [self.uislider setvalue:0.00]; } -(void) writetotextfile:(nsstring*) values : (nsstring*) values2 { //get documents directory: nsarray *paths = nssearchpathfordirectoriesindomains (nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; //make file name write info using documents directory: nsstring *filename = [nsstring stringwithformat:@"%@/slider.txt",documentsdirectory]; //create content - 4 lines of text nsstring *content = [nsstring stringwithformat:@"%@%@%@%@", values , @"\n" , values2 , @"\n" ]; //save content documents directory [content writetofile:filename atomically:yes encoding:nsstringencodingconversionallowlossy error:nil]; nslog(@"%@",documentsdirectory); [self displaycontent]; } -(void) displaycontent{ //get documents directory: nsarray *paths = nssearchpathfordirectoriesindomains (nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; //make file name write info using documents directory: nsstring *filename = [nsstring stringwithformat:@"%@/slider.txt", documentsdirectory]; nsstring *content = [[nsstring alloc] initwithcontentsoffile:filename usedencoding:nil error:nil]; //use simple alert library (see previous post details) nslog(@"%@",content); // [self showemail:filename]; } - (ibaction)sliderchange:(id)sender { uislider *slider = (uislider *)sender; nsstring *newvalue = [nsstring stringwithformat:@"%.2f" , slider.value]; self.uivalue.text = newvalue; valuev = self.uivalue.text; if(slider.value > 30 && slider.value < 50){ audioservicesplaysystemsound(1003); //audioservicesplayalertsound(ksystemsoundid_vibrate); audioservicesplaysystemsound(ksystemsoundid_vibrate); } } - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { homecoming (interfaceorientation != uiinterfaceorientationportraitupsidedown); } @end
when creating new view controller, have instantiate nib file, like:
slidervc = [[sliderviewcontroller alloc] initwithnibname:@"sliderviewcontroller" bundle:nil]
or if utilize storyboards:
slidervc = [self.storyboard instantiateviewcontrollerwithidentifier:@"sliderviewcontroller"];
otherwise there no connection file created in interface builder , ios doesn't know ui elements load view controller.
update: have set string:
ios objective-c uiviewcontroller
Comments
Post a Comment