views:

226

answers:

2

I have a UITableView being shown in a popover. One cell in my table view has a UITextField in it. When the text field is being edited (the keyboard is visible) and I rotate the device from portrait to landscape and then try to scroll the table view, it keeps going past its bounds, instead of stopping and "bouncing".

Does anyone know how to fix this?

A: 

You can try to detect when the device is rotated and call the tableViewController method that adjusts scrolling position of selected cell to the area you need.

Sergei Lost
A: 

You can use following code when rotate device

     - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
      {

        if ([appDelegate.aPopover isPopoverVisible])
       {
        [appDelegate.aPopover dismissPopoverAnimated:NO];

        CGSize size = [self rotatedSize];
        size.height -= [[self.view viewWithTag:154] frame].size.height;

        appDelegate.aPopover.popoverContentSize = size;

        [appDelegate.aPopover presentPopoverFromRect:[[self.view viewWithTag:154] frame]
                                              inView:self.view
                            permittedArrowDirections:UIPopoverArrowDirectionDown
                                            animated:YES];
    }
}

       // for set popoverview size when rotate screen
         -(CGSize)rotatedSize
         {
         UIDeviceOrientation orientation1 = [[UIDevice currentDevice] orientation];
         UIInterfaceOrientation toInterfaceOrientation =  orientation1;
         if ((toInterfaceOrientation == UIInterfaceOrientationPortrait) || (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown))
        {
              return self.view.frame.size;
      }
    else
    {
        return CGSizeMake(self.view.frame.size.height, self.view.frame.size.width);
    }
}

Thank you,

milanjansari
That is a lot of code, something tells me there is an easier way :)
logancautrell