iPad App Store使用UIScrollview和UIPageControl的“精选标签”?

时间:2012-05-10 10:08:59

标签: iphone objective-c uiscrollview ipad

我是iOS开发新手我正在开发一个与iPad中的精选标签完全相似的应用程序。

例如:

纵向模式下的应用程序功能选项卡 http://postimage.org/image/hpfg55zbh/

在scrollview中显示应用

在横向模式下

http://postimage.org/image/dpwnbnr4n/

OHK NOW:我正在做的是,我正在创建图片中单元格显示大小的视图。让我们说如果我有25个应用程序,所以我创建25个视图并在该视图上加载应用程序的图像和描述。当用户从纵向模式旋转到横向我时 重新创建视图因为我正在显示:

人像模式:每页5行X 2列。 横向模式:每页3行X 3列。

重新创建和发布视图真的不是一个好习惯。任何人都可以指导我或建议我做其他任何技巧吗?我必须滚动浏览和页面控制这是肯定的,但我想摆脱这种重新创建方法。

**

  

通过编程完成开发,不使用任何NIB

** 寻找最佳答案:) ...请帮助我

1 个答案:

答案 0 :(得分:0)

我想说当你的视图加载时你会进行初始创建,当你旋转时,你只需要通过编辑它们的框架来重新定位视图。由于您没有使用笔尖,我假设您已经具有相应定位视图的逻辑。

所以也许你有类似的东西:

//Assuming you have these members
UIView *yourContainer_;
NSArray *subViews_;

- (void)viewDidLoad
{
    if(UIUserInterfaceOrientationIsLandscape(self.interfaceOrientation))
    {
        //create your views and add to container
    }
    else
    ....
}

-(void)willRotateToInterfaceOrientation: (UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration
{
     if(UIUserInterfaceOrientationIsLandscape(orientation)
     {
          yourContainer_.frame = CGRectMake(?,?,?,?); //whatever the new size needs to be
          //then loop through all of your sub views to reposition their frames individually within the new container to match the new size and layout
     }
     else
     {
          //the same thing for this orientation
     }

}