Tuesday, June 4, 2013

UIScrollView scrollIndicatorInsets example in Objective C (iOS).


UIScrollView scrollIndicatorInsets

The distance the scroll indicators are inset from the edge of the scroll view.

@property(nonatomic) UIEdgeInsets scrollIndicatorInsets

Discussion of [UIScrollView scrollIndicatorInsets]
The default value is UIEdgeInsetsZero.

UIScrollView scrollIndicatorInsets example.
Actually, it is possible by changing the scrollIndicatorInsets property to restrict the indicator to a small area on the left side:

tableView.scrollIndicatorInsets = UIEdgeInsetsMake(0,0,0,tableView.bounds.size.width-10);

Example of [UIScrollView scrollIndicatorInsets].
i.e use UIEdgeInsetMake( <top> , <left>,<bottom>,<right>); for this. i.e for your case

yourScrollView.scrollIndicatorInsets   = UIEdgeInsetMake(0, 0,bottomInset,0); //Here bottom inset would be the value you have right now .

UIScrollView scrollIndicatorInsets example.
- (void)keyboardWillShow:(NSNotification*)aNotification{
    if(!self.keyboardShown){
        NSDictionary* info = [aNotification userInfo];
       
        // Get the size of the keyboard.
        NSValue *aValue = [info objectForKey:UIKeyboardBoundsUserInfoKey];
        CGSize keyboardSize = [aValue CGRectValue].size;
       
        //determin the bottom inset for the table view
        UIEdgeInsets settingsTableInset = self.settingsTableView.contentInset;
        CGPoint tableViewScreenSpace = [self.settingsTableView.superview convertPoint:self.settingsTableView.frame.origin toView:nil];
        CGFloat tableViewBottomOffset = InAppSettingTableHeight-(tableViewScreenSpace.y+self.settingsTableView.frame.size.height);
        settingsTableInset.bottom = keyboardSize.height-tableViewBottomOffset;
       
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:InAppSettingKeyboardAnimation];
        [UIView setAnimationBeginsFromCurrentState:YES];
        self.settingsTableView.contentInset = settingsTableInset;
        self.settingsTableView.scrollIndicatorInsets = settingsTableInset;
        [UIView commitAnimations];
       
        self.keyboardShown = YES;
    }
}

End of UIScrollView scrollIndicatorInsets example article.