开发者

scale a UITableView to fullscreen from inside a UIScrollView

Having failed in trying to puzzle together different sources to any form of coherent approach or concept I turn, once again to the learned people of StackOverflow. My problem is quite specific and maybe that's why I'm having trouble finding information that fits or maybe I just suck at searching. Either way, here goes.

I am building an app which has a UIScrollView populated with UIViews which in turn are populated with UITableViews. I have paging and everything set up and working properly. Basically, I am trying to mirror the functionality of Safari's (mobile) tab behaviour, or (even closer to what I'm trying to achieve) Tweetdeck's main page. I couldn't post an image but if you click on the link below you'll see what I mean.

http://www.redmondpie.com/wp-content/uploads/2009/07/TweetdeckIphone04.jpg

The reason for the UITableViews are inside UIViews is that this was the only way I could figure out to make the tableViews have a space between them, instead of being right next to each other. I tried setting the size of the tableViews and the inset of the scrollView, among many things but the tableviews always ended up filling the entire scrollView. In any case, that is a separate issue, possibly

As I click on a tableView/UIView inside the scr开发者_运维技巧ollView I want that tableView/UIView to scale up and fill the entire screen (minus tabBar and navigationBar), and then I should be able to scale it back down by pressing the back button on the navigationBar.

Any information or nudges in the right direction is greatly appreciated.


I am doing something similar in my app:

-(void)displayPage:(int)targetedPage {
    ...
    [UIView beginAnimations:@"MultiViewAnimate" context:nil];
    [UIView setAnimationDuration:0.3];

    //animate the frame
    //targetedPage is the index (table view) that should be displayed
    [(UITableView *)[tableViews objectAtIndex:targetedPage] setFrame:CGRectMake(0, 0, 320, 372)];
    [(UITableView *)[tableViews objectAtIndex:targetedPage] setUserInteractionEnabled:YES];
    ...

    [UIView commitAnimations];
}

-(void)displayMultiView:(id)sender {
    ...
    [UIView beginAnimations:@"MultiViewAnimate" context:nil];
    [UIView setAnimationDuration:0.3];

    //animate the frame
    //targetedPage is the index (table view) that I was previously looking at full screen
    [(UITableView *)[tableViews objectAtIndex:targetedPage] setFrame:CGRectMake(60, 70, 200, 232)];
    [(UITableView *)[tableViews objectAtIndex:targetedPage] setUserInteractionEnabled:NO];
    ...

    [UIView commitAnimations];
}

In this code tableViews is an array of all the UITableViews that the scrollView contains.

I am doing a little more than this because I am taking a screenshot of my view and using a UIImageView for the scaled view and then animating back out to the respective UIWebView. One advantage to that approach is that I can just attach a UITapGestureRecognizer to the UIImageView and not have to mess with turning off userInteraction on the UITableView.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜