Objective c 如何在navigationController下方放置图片?

Objective c 如何在navigationController下方放置图片?,objective-c,uinavigationcontroller,Objective C,Uinavigationcontroller,我想为我的乐队制作一个iPhone应用程序。 我想知道如何在navigationController下方放置一张图片,这张图片只有在下拉时才可见(让我们浏览一下这个应用程序): 非常感谢 使用scrollview方法 - (void)scrollViewDidScroll:(UIScrollView *)scrollView { CGPoint offset = scrollView.contentOffset; CGRect bounds = scrollView.bou

我想为我的乐队制作一个iPhone应用程序。 我想知道如何在navigationController下方放置一张图片,这张图片只有在下拉时才可见(让我们浏览一下这个应用程序):

非常感谢

使用scrollview方法

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{  
    CGPoint offset = scrollView.contentOffset;
    CGRect bounds = scrollView.bounds;
    CGSize size = scrollView.contentSize;
    UIEdgeInsets inset = scrollView.contentInset;
    float y = offset.y + bounds.size.height - inset.bottom;
    float h = size.height;

    if(scrollView.contentOffset.y < 0.0f && scrollView.contentOffset.y > -80.0f) 
    {
       //
        display your image at this point
        NSLog(@"\n pos: %f of %f", y, h);
    }
-(无效)scrollViewDidScroll:(UIScrollView*)scrollView
{  
CGPoint offset=scrollView.contentOffset;
CGRect bounds=scrollView.bounds;
CGSize size=scrollView.contentSize;
UIEdgeInsets inset=scrollView.contentInset;
浮动y=偏移量.y+bounds.size.height-插入底部;
浮动h=尺寸。高度;
if(scrollView.contentOffset.y<0.0f&&scrollView.contentOffset.y>-80.0f)
{
//
此时显示您的图像
NSLog(@“\n位置:%f,共%f”,y,h);
}

您可以更轻松地完成:

UIScrollView*scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0,03201000)]; [self.view addSubview:scrollView]

这将添加一个滚动视图:) UIImageView*imgView=[[UIImageView alloc]initWithFrame:CGRectMake(0,0320,您想要的高度)]; imgView.image=[UIImage imageName:@“band.png”]; [滚动视图添加子视图:imgView]

这将添加您乐队的图片,该图片必须位于scrollView顶部的Projectfolder中,因此如果向下滚动,图片将随之显示:)

在这里创建一个UINAVIGATIONBAR

[self.view addSubview:navigationBar]


//^它必须是self.view而不是scrollView,否则导航栏也会移动

将照片和表格放在
UIScrollView
的内部,然后设置
UIScrollView
contentOffset
,以便默认情况下表格位于顶部。