ios - ViewController infinite loop after modifying Storyboard -
i'm having navigation / viewcontroller hierarchy problem ever since implementing library side-shelf navigation (https://github.com/socialobjects-software/amslidemenu). implementation of library works fine demo viewcontrollers (as can seen on linked github page), when adjusted include actual viewcontrollers had been working (which had worked fine on own), navigation flow breaks down.
my app's viewcontrollers structured follows:
- navigation controller
- login viewcontroller
- main viewcontroller (where drawer-nav library kicks off)
- slidemenulefttableview
- navigation controller
- itemstable viewcontroller
- addphoto viewcontroller
- additemdetails viewcontroller
- navigation controller
- demo viewcontroller
- navigation controller
- slidemenulefttableview
before implementing shelf-navigation library, storyboard consisted of following viewcontrollers, , not encountering issues:
- navigation controller
- login viewcontroller
- itemstable viewcontroller
- addphoto viewcontroller
- additemdetails viewcontroller
at itemstable viewcontroller, expected, users see tableview of items have added. before (we're still @ point), users click "add" button itemstable viewcontroller , go addphoto viewcontroller. user chooses photo , taken additemdetails viewcontroller, user adds title photo.
here, though, breaks down.
the item upload works, newly added item shows in parse data browser, in itemstableview after close , relaunch app. when click button add item within additemdetails viewcontroller, instead of taking me tableviewcontroller list of items updated include new item, taken uicamerapicker, caught in loop of adding photos items, never getting tableviewcontroller @ them. when click cancel button on uicamerapicker warning message:
2014-05-31 23:04:26.312 getga[6872:90b] presenting view controllers on detached view controllers discouraged <uinavigationcontroller: 0x10b637f60>.
addphoto viewcontroller (where i'm getting stuck in loop)
-(void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { if ([segue.identifier isequaltostring:@"givephototogivedetailssegue"]){ if ([segue.destinationviewcontroller iskindofclass:[jfgiveitemdetailsvc class]]){ jfgiveitemdetailsvc *targetvc = segue.destinationviewcontroller; targetvc.giveitemimage = self.giveitemimage; } } } -(void)viewdidappear:(bool)animated { uiimagepickercontroller *picker = [[uiimagepickercontroller alloc]init]; picker.delegate = self; if ([uiimagepickercontroller issourcetypeavailable:uiimagepickercontrollersourcetypecamera]){ picker.sourcetype = uiimagepickercontrollersourcetypecamera; } else if ([uiimagepickercontroller issourcetypeavailable:uiimagepickercontrollersourcetypesavedphotosalbum]){ picker.sourcetype = uiimagepickercontrollersourcetypesavedphotosalbum; } [self presentviewcontroller:picker animated:yes completion:nil]; } -(void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info { uiimage *image = info[uiimagepickercontrollereditedimage]; if(!image) image = info[uiimagepickercontrolleroriginalimage]; self.giveitemimage = image; [self dismissviewcontrolleranimated:yes completion:nil]; [self performseguewithidentifier:@"givephototogivedetailssegue" sender:self]; } - (void)imagepickercontrollerdidcancel:(uiimagepickercontroller *)picker{ [self.navigationcontroller poptorootviewcontrolleranimated:yes]; }
additemdetails viewcontroller (which should send me itemstable viewcontroller)
-(bool)textfieldshouldreturn:(uitextfield *)textfield { nsstring *nameforgiveitem = self.giveitemtitletextfield.text; nsdata *giveitemimagedata = uiimagepngrepresentation(self.giveitemimage); pffile *giveitemimagefile = [pffile filewithname:nameforgiveitem data:giveitemimagedata]; pfobject *giveitemphoto = [pfobject objectwithclassname:@"giveitemphoto"]; giveitemphoto[@"imageowner"] = [pfuser currentuser]; giveitemphoto[@"imagename"] = nameforgiveitem; giveitemphoto[@"imagefile"] = giveitemimagefile; [giveitemphoto saveinbackground]; pfobject *giveitem = [pfobject objectwithclassname:@"giveitem"]; giveitem[@"giveitemtitle"] = self.giveitemtitletextfield.text; giveitem[@"giver"] = [pfuser currentuser]; [giveitem setobject:giveitemphoto forkey:@"giveitemphoto"]; [giveitem saveinbackground]; [self.navigationcontroller poptoviewcontroller:[self.navigationcontroller.viewcontrollers objectatindex:1] animated:yes]; return yes; }
i stuck @ same issue. here did, in - (void)viewdidappear:(bool)animated
function write this:
uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main" bundle: nil]; mjloginviewcontroller *logincontroller = [storyboard instantiateviewcontrollerwithidentifier:@"loginviewcontroller"]; [self.navigationcontroller pushviewcontroller:logincontroller animated:yes];
if using ios 7 storyboardwithname:@"main"
same you. mjloginviewcontroller class view controller in main.storyborad , instantiateviewcontrollerwithidentifier:@"loginviewcontroller"
here should write storyboard id name. if have not given 1 go on assign one.
run , work.
Comments
Post a Comment