Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView get UIScrollView for customization

I have category for UIScrollView for customization

I need get UIScrollView.

I try

UIScrollView *scroll = nil;
for (UIView* subview in self.tableView.subviews) {
    NSLog(@"%i", self.tableView.subviews.count);

    if ([subview isKindOfClass:[UIScrollView class]]) {
        scroll = (UIScrollView *)subview;
        //some code
    }
}

But it doesn't work. How I can get ScrollView? Thanks

like image 998
Alexander Avatar asked Nov 30 '22 01:11

Alexander


2 Answers

UITableView is a subclass of UIScrollView, not a subview (or vice-versa as your code tries), so you should just use the table view directly.

like image 185
Wain Avatar answered Dec 09 '22 17:12

Wain


UIScrollView is not subview but UIScrollView is superclass of UITableView you can call method or get variable of UIScrollView by through UIScrollView, If you want to get UIScrollView you can use by this

var scroll = self.tableView as UIScrollView
//some code

Or you want to compare you can use

if scrollView == self.tableView {
    //some code 
}
like image 45
Saharat Sittipanya Avatar answered Dec 09 '22 17:12

Saharat Sittipanya