Domanda

I added tableview to scrollview programmatically but it is not scrolling. While i tried the same using XIB. but it is working fine.

here is my code

CGRect frame = CGRectMake(30, 30.0f, 900, 300.0f);

eappTable = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]  style:UITableViewStylePlain];

eappTable.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;

eappTable.delegate = self;

eappTable.dataSource = self;

eappTable.scrollEnabled = YES;

eappTable.scrollsToTop = YES;

[eappTable reloadData];

[scrollView addSubview:eappTable];
È stato utile?

Soluzione

eappTable = [[UITableView alloc] nitWithFrame:YourSize style:Table_Style]];
eappTable.delegate = self;
eappTable.dataSource = self;
eappTable.scrollEnabled = YES;
[scrollView addSubview:eappTable];

And set self.scrollView.contentSize

Altri suggerimenti

You have to set the Content Size of ScrollView.

Hope it Helps !!!

Try to enable bouncing (because if all cells size are smaller than the uitableview size it self, it won't scroll if bounce is set to NO) :

eappTable.bounces = YES;

[eappTable  setContentSize:CGSizeMake(320, 680)];

I know this is not the answer you are looking for. But I would like to mention one point : Never add tableview as the subview of your scrollview.

Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top