5

IKImageView にスクロールバーを追加しようとしています。基本的に現時点では、画像をビューにロードするプログラムの例がいくつか必要です。ウィンドウが小さすぎる場合は、正しいことを行うスクロールバーを設定します...

Apple 開発サイトでこれらの例が見つからないのはなぜですか?

追加情報:

ImagekitDemo を見た後、IKIMageView を ScrollView に埋め込む必要があることは明らかです。(そして、どういうわけか、IKImageView の has___Scroller プロパティが YES になります...)

ただし、現在 (これは ImageKitDemo にも当てはまります) スクロール バーは 1 つだけ (またはどちらも) 必要ない限り問題ありません。ただし、両方が必要になり、ウィンドウのいずれかのサイズが画像よりも小さくなるとすぐに、両方のスクロールバーが消えます。

マウスのスクロールは引き続き機能します。

4

2 に答える 2

0

ZoomViewController.h

@interface ZoomViewController : UIViewController <UIScrollViewDelegate>
{
    ForecastImage* detailImage; // wrapper class around UIImage (optional - could just be UIImage)

    IBOutlet UIImageView* imageView;
    IBOutlet DoubleTapScrollView* zoomableScrollView;
}

@property (readwrite, nonatomic, retain) ForecastImage* detailImage;

- (IBAction) dismissZoomViewController;

- (UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView;

- (void) scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale;

@end

ZoomViewController.m

@implementation ZoomViewController

@synthesize detailImage;

- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)viewWillAppear:(BOOL)animated
{
    [imageView setImage:[self.detailImage renderedImage]];

    [zoomableScrollView setContentSize:[[imageView image] size]];
    [zoomableScrollView setMaximumZoomScale:5.0];
    [zoomableScrollView setMinimumZoomScale:0.25];
}

- (void) viewDidAppear:(BOOL)animated
{
    self.navigationItem.title = [SearchService getDisplayName:[self.detailImage forecastArea]];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc
{
    imageView.image = nil;
    self.detailImage = nil;

    [super dealloc];
}

- (IBAction) dismissZoomViewController
{
    [self dismissModalViewControllerAnimated:YES];
}

#pragma mark Pinch-n-Zoom

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return imageView;
}

- (void) scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
{
    CGSize newSize = CGSizeMake(imageView.image.size.width * scale, imageView.image.size.height * scale);
    [scrollView setContentSize:newSize];
}

@end
于 2010-01-21T13:23:32.223 に答える
0

開始するのに最適な場所は、Scroll View プログラミング ガイドです。基本的に、NSScrollView 内に IKImageView を配置する必要があります。IKImageView のサイズが NSScrollView の表示可能な四角形を超える場合、スクロールバーが表示されます。

次のサンプルでは、​​IKImageViewを使用して、さまざまなズームおよびサイズ変更操作を実行します。

于 2010-01-15T08:31:04.063 に答える