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

How to Make REST api call in Objective-C.

Launch iPhone simulator without Xcode.

Hacker Rank problem solution