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

Launch iPhone simulator without Xcode.

How to Make REST api call in Objective-C.

id vs NSObject