Basically on the click of a cell, I want the table to animate up (shortening it’s height) and a ‘detail’ view to slide up taking up the space now available..
I have the tableView shortening properly, but I am having problems getting the second view to slide in..
CGRect frame = self.tableview.frame; // (drilldown table)
if(frame.size.height > 600)
{
CGRect detailFrame = StudyDetailView.view.frame; // (detailed view I want to slide up
detailFrame.origin.y = (frame.size.height-200);
self.tableview.autoresizingMask = UIViewAutoresizingNone;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.3];
StudyDetailView.view.frame = detailFrame; // <-- this does not work.
self.tableview.frame = CGRectMake(0,0,frame.size.width,frame.size.height-200); // <-- this works.
[UIView commitAnimations];
}
Update
My fix:
StudyListDetailController.m
- (void)viewDidLoad {
CGRect frame = self.view.frame;
self.view.frame = CGRectMake(0,900,frame.size.width,frame.size.height);
[super viewDidLoad];
}
In my table row select…
if(frame.size.height > 600)
{
CGRect detailFrame = StudyDetailView.view.frame;
self.tableview.autoresizingMask = UIViewAutoresizingNone;
detailFrame.origin.y = (frame.size.height-200);
detailFrame.size.height = 200;
[self.view addSubview:StudyDetailView.view];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.3];
self.tableview.frame = CGRectMake(0,0,frame.size.width,frame.size.height-200);
StudyDetailView.view.frame = detailFrame;
[UIView commitAnimations];
}
where do you initially set
StudyDetailView.view.frame? It looks like you’ve only set the Y value.Try doing
NSLog(NSStringFromCGRect(detailFrame));and see what shows up in the console, I’m guessing only the y value will be set, and the width and height are just 0.