// 選擇框
uipickerview
*pickerview = [[
uipickerview
alloc] initwithframe:
cgrectmake(0
, 100
, 320
, 216
)];
// 顯示選中框
pickerview.showsselectionindicator=
yes;
pickerview.datasource =
self
;
pickerview.delegate =
self
;
[self
.view addsubview:pickerview];
[pickerview release];
_protimelist = [[
nsarray
alloc]initwithobjects:
@"1"
,@"2"
,@"3"
,@"4"
,@"5"
,@"6"
,@"7"
,@"8"
,@"9"
,@"10"
,nil];
_protitlelist = [[
nsarray
alloc]initwithobjects:
@"1"
,@"2"
,@"3"
,@"4"
,@"5"
,@"6"
,@"7"
,@"8"
,@"9"
,@"10"
,nil
// pickerview 列數
- (nsinteger
)numberofcomponentsinpickerview:(
uipickerview
*)pickerview
// pickerview 每列個數
- (nsinteger
)pickerview:(
uipickerview
*)pickerview numberofrowsincomponent:(
nsinteger
)component
return
[_protimelist count]; }
// 每列寬度
- (cgfloat
)pickerview:(
uipickerview
*)pickerview widthforcomponent:(
nsinteger
)component
return
180;}
// 返回選中的行
- (void
)pickerview:(
uipickerview
*)pickerview didselectrow:(
nsinteger
)row incomponent:(
nsinteger
)component
else}
//返回當前行的內容,此處是將陣列中數值新增到滾動的那個顯示欄上
-(nsstring
*)pickerview:(
uipickerview
*)pickerview titleforrow:(
nsinteger
)row forcomponent:(
nsinteger
)component
else
}
UIPickView的基本使用
uipickview和tableview一樣,想要展示資料也要設定資料來源和 設定資料來源 self pickview.datasource self 設定 self pickview.delegate self 遵守資料來源,協議 inte ce viewcontroller property w...
修改UIPickView的高度
發現了乙個問題,uipickerview不能改變小於216的高度,利用setframe方法無法修改uipickerview的高度。解決方法 1 加上pickerview.autoresizingmask uiviewautoresizingflexibleheight uiviewautoresiz...
UIPickView的簡單介紹
設定uipickview的時候,我們主要需要設定一下下面的兩個屬性 uipickerview pickview1 pickview1 uipickerview alloc initwithframe cgrectmake 0,100,300,200 pickview1.delegate self p...