我想水平滾動選取器視圖,這是我的代碼。如何增加選取器視圖(轉換的pickerview)寬度?
在viewDidLoad中我這樣做,
CGRect frame = horizontalPickerView.frame;
frame.size.width = 50;
frame.size.height = 216;
frame.origin.x=90;
frame.origin.y = 200;
horizontalPickerView.frame = frame;
horizontalPickerView.transform = CGAffineTransformMakeRotation(3.14159/2);
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{
UILabel *lbl = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 30, 20)] autorelease];
lbl.transform = CGAffineTransformMakeRotation(-3.14159/2);
lbl.text = @"hi";
return lbl;
}
但問題是我不能夠改變選擇器視圖超過216.0的寬度,如果我嘗試這樣做有留下了黑色的背景。
CorrectImage http://img709.imageshack.us/img709/6982/picture5g.png這是正確的圖像
現在,如果我這樣做
CGRect frame = horizontalPickerView.frame;
frame.size.width = 50;
frame.size.height = 300;
frame.origin.x=120;
frame.origin.y = 200;
horizontalPickerView.frame = frame;
horizontalPickerView.transform = CGAffineTransformMakeRotation(3.14159/2);
我得到這個image http://img46.imageshack.us/img46/2792/picture6b.png
我見過像Seelibrity的應用程序,其中選擇器具有寬度以適應屏幕。 請幫我解決這個問題?
或者他可以使用UIScrollView。 – 2009-12-23 20:14:35
考慮到數據源和單元格顯示方法已經存在,UITableView將是更好的選擇。 UIScrollView將要求他重新發明UIPickerView的許多功能。即使使用UITableView也需要大量的自定義插圖和疊加子視圖,以及一些管理當前選定行的機制。 – 2009-12-24 22:21:49