2011-09-26 30 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

相關問題