what i'm trying do:
the following bit of code 2 buttons on page. page part of array of pages (which stored in self.parent; stores index has in said array in self.index). 2 buttons used navigate forwards , backwards in array of pages. if tries go forward hits end of array, should go first page; likewise going , hitting beginning of array.
@ibaction func previousbutton(sender: anyobject) { self.prev() } @ibaction func nextbutton(sender: anyobject) { self.next() } func next(){ if let _parent = self.parent{ if self.index != _parent.getsize()-1 { self.view.addsubview(_parent[self.index+1].view) } else{ self.view.addsubview(_parent[0].view) } } else{ println("this page not part of list") } } func prev(){ if let _parent = self.parent{ if self.index != 0 { self.view.addsubview(_parent[self.index-1].view) } else{ self.view.addsubview(_parent[_parent.getsize()-1].view) } } else{ println("this page not part of list") } } problem is:
edit: crashes have nothing if statements , isn't random either; crashes when hit next button tenth time, previous button tenth time (ten number of pages have in list; if add more pages, number changes accordingly), , when press prev after pressing next or pressing next after pressing next.
i figured out problem: not switching between pages, adding 1 on top of others; crash occurs when attempt show page loaded (and still somewhere beneath stack of pages).
now need find better way switch between them.
Comments
Post a Comment