Scroll The Content Of View

Code To Scroll The Content of View


//First of all make scroll view and connect it
//in .h file



@property(nonatomic,retain)IBOutlet UIScrollView *srlView;



//in .m file


[self scrollViewToCenterOfScreen:self.view];


//Scroll the view
- (void)scrollViewToCenterOfScreen:(UIView *)theView 
{
    CGFloat viewCenterY = theView.center.y;
    CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];
    CGFloat availableHeight = applicationFrame.size.height - 250// Remove area covered by keyboard
    CGFloat y = viewCenterY - availableHeight / 2.0;
    if (y < 0) {
        y = 0;
    }
    [srlView setContentOffset:CGPointMake(0, y) animated:YES];
}




Comments

Popular posts from this blog

Hacker Rank problem solution

How to Make REST api call in Objective-C.

Building and Running Python Scripts with Xcode