Dynamic Table View height based on ContentSize of table view...
Add an Observer at which situation you want to maintain dynamic height for tableview...
[self.searchTableView addObserver:self forKeyPath:@"contentSize" options:0 context:NULL];
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if (self.searchTableView.contentSize.height < 250) {
self.searchTableView.frame = CGRectMake(self.searchBar.frame.origin.x, self.searchBar.frame.origin.y+44, self.searchTableView.frame.size.width,self.searchTableView.contentSize.height);
// CGRect frame = self.searchTableView.frame;
// frame.size = self.searchTableView.contentSize;
// self.searchTableView.frame = frame;
}
}
No comments:
Post a Comment