0

I have an array of views with subviews inside. Once the last subview is displayed I want to run a different statement from an if else statement. So like this:

  let subviews: Array = self.view.subviews
        if subviews.endIndex {
            return 4
        }else{
           return 0
        }

Although I know this code is incorrect but I am trying to get the last last element in the subviews array.

Henry Brown
  • 2,219
  • 8
  • 31
  • 48
  • I don't think that's right. I want the if statement to only run if that particular subview is in view – Henry Brown Aug 17 '16 at 13:58
  • 2
    If the view belongs to the `subviews` array then certainly it's a subview of that view. Or are you asking for something else? If yes, please update the question – Cristik Aug 17 '16 at 14:00
  • The view has four subviews. When the fourth subview comes into view I want to return 4 by the if statement, otherwise when the other three subviews are in view I want to return 0 by the else statement – Henry Brown Aug 17 '16 at 14:11
  • @HenryBrown, your question really needs to be clarified it sounds like gibberish in its current form, honestly; it does not make any sense. _who_ calls the actual `if ... else ...` statement, and _who_ needs the returned value? – holex Aug 17 '16 at 14:24
  • "come into view" means when that particlar subview is shown to the user. As these subviews are part of a pageViewController so the user scrolls through the views. Once the user gets to subview 4 I want return 0. – Henry Brown Aug 17 '16 at 14:25
  • Sorry, I am new and trying to explain the best I can. This question is basically what I am trying to achieve, although it was never answered: http://stackoverflow.com/questions/36391401/hide-dots-on-final-page-of-uipageviewcontroller-swift – Henry Brown Aug 17 '16 at 14:30

0 Answers0