0

我有一个大问题,我不知道如何解决......

我的 UIToolbar 应该是固定在屏幕底部的,在整个屏幕上都出现了缩放。

就我而言,我有:

一个 UIViewController

使用 UIScrollView 滚动图像。

所以我需要屏幕底部的工具栏,但它取代了图像滚动并占据了所有屏幕。这发生在我从 iphone Xcode 的 V2 移动到 V3 时……在它显示正常之前……

我将简要解释我是如何初始化这些东西的:在 h 文件中 UIScrollView *myScroll; 在 .M 文件中,我有 UIToolbar *toolbar;

然后在 (void)viewDidLoad {

toolbar = [UIToolbar new];
toolbar.barStyle = UIBarStyleDefault;

toolbar.frame = CGRectMake(0, 410, 320, 50);
------------------------

myScroll.contentSize = CGSizeMake(myImage.frame.size.width, myImage.frame.size.height);

myScroll.maximumZoomScale = 4.0;
myScroll.minimumZoomScale = 1;

myScroll.clipsToBounds = YES;
CGRect frame2 = myImage.frame;

frame2.origin.y=frame2.origin.y+40;
myScroll.contentOffset=frame2.origin;



myScroll.delegate = self;

[myScroll addSubview:myImage];  

    [myScroll.superview addSubview:toolbar];    

所以工具栏上设置的框架不起作用......它会在整个屏幕上设置自己......

我不想扩展 UIScrollView,因为我想要一些与此类功能相关的按钮..

我想要完成的功能是拥有一张可缩放、可平移的照片和一些选项,用于评论、投票和上一页。下一个等..从工具栏替代文本 http://www.freeimagehosting.net/image.php?ef28ce0bb4.jpg

这是一个预览:

4

1 回答 1

1

最简单的方法是使用 Interface Builder 来设置您的工具栏。

只需将 UIToolbar 放在您的窗口中并将其连接到您的视图控制器。以下是您以编程方式设置按钮的方式,但您也可以轻松地将它们添加到 IB 中并将它们连接到那里。

- (void)viewDidLoad {
    UIBarButtonItem *addButton = [[UIBarButtonItem alloc] 
                              initWithBarButtonSystemItem:UIBarButtonSystemItemAdd 
                              target:self 
                              action:@selector(insertNewObject)];

    NSArray *items = [NSArray arrayWithObject:addButton];
    self.toolbar.items = items;
}
于 2010-02-07T00:51:35.160 回答