0

iPad用のブックアプリケーションを開発するタスクがあります。投稿に投稿した画像のような機能を持っています。

そして、画面中央のメインビューのサブビューとして、ボタンクリックでサブビューを開発するタスクがあります。

ビューを開発する必要があります画像で与えられているのはこのようなものです。。上記のスクリーン ショットのようなビューを開発する方法についてのヒントを教えてください。

また、その例またはサンプルコードを提供してください。

前もって感謝します。

4

1 に答える 1

0

Create a UIScrollview, which has paging enabled. (can be done either in Interface Builder or in code). Assign it to a property inside your viewcontroller. It could look like this:

 // this is how it looks when you do it in code yourself
@property (weak,nonatomic) UIScrollView *theScrollView;

// this is how it looks when you let Interface Builder create your property for you
@property(weak,nonatomic) IBOutlet UIScrollView *theScrollView;

Notice that the property is weak. Because your view is added to your viewcontrollers main view as a subview, that view already has a strong pointer to it, so you don't need your property to be strong. If you want to be able to remove add readd your scrollview from your main view, then you should use a strong pointer, or else your scrollview will get deallocated.

Now, in code, add your subviews to it, with proper incrementing x-offset and then when you tap the button have a function like this handling the tap:

/* i assume your scrollview is a property on your viewcontroller with the name "theScrollView */
- (void) handleFeaturedTap
{
    /* 
    get the offset of your subview, to which you want to scroll, not shown.
    */
    [self.theScrollView scrollRectToVisible:theRectYouWantToShow animated:YES];
}

This will then have the scrollview slide to your desired area, which in your case would be the position where you added your view which holds the featured books.

コードまたは Interface Builder で UIScrollview を作成する方法がわからない場合は、http://developer.apple.com/library/ios/#documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.htmlを読むことをお勧めします。 UIView リファレンスも参照し、Interface Builder の使用方法に関するいくつかのチュートリアルを確認してください。

于 2012-05-07T06:53:24.420 に答える