2011-09-26 71 views
0

我要给它包含按钮和TextView的。什么我想要的是垂直滚动视图...反刍能跟大家帮我出下面是代码...如何添加一个垂直滚动视图

- (id)initWithItem:(NSString *)theItem Title:(NSString *)title Description:(NSString *)detaildesc{ 
if (self = [super initWithNibName:@"Secondetailview" bundle:nil]) { 
self.theItem1=theItem; 
    self.theTitle=title; 

    UILabel *tit = [[[UILabel alloc] initWithFrame:CGRectMake(10, 10, 200, 25)] autorelease];       
    [tit setBackgroundColor:[UIColor clearColor]]; 
    [tit setTextColor:[UIColor whiteColor]]; 
    [tit setText:self.theTitle]; 
    [tit setFont:[UIFont boldSystemFontOfSize:16]]; 
    NSLog(@" wii this is cool:%@",detaildesc);    
    [self.view addSubview:tit]; 


    label1.text=detaildesc; 
    label1.numberOfLines=4; 
    label1.textColor=[UIColor grayColor]; 


} 

    return self; 
    } 

enter image description here

回答

1

将UIScrollview放在选项卡内,然后将UIScrollView的contentSize调整为所有控件总高度的大小。

+0

我已经添加uiscroll视图在界面builder.I中号不能dat..could后进行û修改去上面的代码.... – kingston

+0

@kingston,如果你有一个带有nib的uiviewcontroller,删除视图,添加一个uiscrollview,将uiscrollview作为uiviewcontroller的视图链接,然后在viewDidLoad中添加下面的代码:self.scrollView.contentSize = CGSizeMake(320,500);其中500将是整个事物的总高度。 – Jano

+0

我添加上面的行即时通讯得到一个错误,说scrollView未声明..如果我添加滚动视图作为IBoutlet和链接查看,即使这并不工作 – kingston

0

在contentSize你必须增加Y值

+0

我已经删除了uiviewcontroller,并添加了uiscrollview我链接到uiview ...可以ü帮助我进一步进行....我应该在uiiew中添加什么,以便我具有滚动效果 – kingston

+0

添加som63.e06 +3。 scrollview.contentSize = CGSizeMake(320,600); – Tendulkar

+0

为scrollview添加一些标签和按钮。然后scrollview.contentSize = CGSizeMake(320,500);它添加了滚动效果 – Tendulkar

相关问题