1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

scrollview scrolling when it shouldn't

Discussion in 'iPhone/iPad Programming' started by straber, Sep 17, 2012.

  1. macrumors member

    I have a UIScrollView with a tall view that has a lot of controls on it. Near the bottom of the ScrollView I have a button and some text fields. When I click the button, the scroll view scrolls up a little bit, which is not what I want and I can find no code anywhere that would cause it to scroll. I set breakpoints on every line of code that scrolls the scroll view, but the program never breaks on one of them when the button is clicked. Does anyone have any idea what could be causing the scrolling?

    I'd really appreciate any help, I've already pulled enough hair out over this one.
  2. Moderator


    Staff Member

    You should, at the very least, provide the code that is run when the button is clicked.
  3. macrumors member

    button code

    The code that executes when the button is clicked is this:

    - (IBAction)addPersonTapped {
        FFSAppDelegate *appDelegate = (FFSAppDelegate *)[[UIApplication sharedApplication] delegate];
        if (appDelegate.currentCID == nil) {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Select Association" message:@"You must first select an association by tapping the 'Select Association' button at the top." delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
            [alert show];
        else {
            if (peopleCategoryPicker == nil) {
                self.peopleCategoryPicker = [[FFSPeopleCategories alloc] initWithStyle:UITableViewStylePlain];
                peopleCategoryPicker.delegate = self;
                self.peopleCategoryPickerPopover = [[UIPopoverController alloc] initWithContentViewController:peopleCategoryPicker]; 
            [self.peopleCategoryPickerPopover presentPopoverFromRect:[txtPeopleCategories bounds] inView:txtPeopleCategories permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];    
        FFSPerson *newPerson = [[FFSPerson alloc] init];
        [addedPeople addObject:newPerson];
        minPeopleSliderLabel.text = @"1";
        maxPeopleSliderLabel.text = [NSString stringWithFormat:@"%i", [addedPeople count]];
        peopleSlider.maximumValue = [addedPeople count];
        peopleSlider.value = [addedPeople count];
    Basically, it displays a popover pointing to a textfield, then creates a new instance of a custom object, adds it to an array, sets the text on some labels, and changes some properties on a slider. Nowhere in the function does it do anything with the scrollview or call another function, that's why I'm so confused.
  4. macrumors 68030


    Just a hunch

    When you say by "a small amount" how much is it scrolling?
    Is the amount the same or random?
    Would this small amount be say the amount of movement a figure would have while tapping the button?
    If your really careful could you tap the button without scrolling?

    If the answer is yes then it might be time to read up on Touch event handling.
    It could be that your button isn't cancelling the touch event an it's still getting passed up the chain to the scroll view which is still responding to it.

Share This Page