2013-07-12 86 views
2

這裏是我的代碼,我用谷歌地圖和UIPickerViewUIPickerView不滾動

-(void)loadView 
{ 

GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 longitude:151.20 zoom:14]; 
mapViewCustomer = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 
mapViewCustomer.myLocationEnabled = YES; 

// mapView_ = [[GMSMapView alloc]initWithFrame:CGRectMake(0, 45, self.view.frame.size.width, self.view.frame.size.height)]; 
// [self.view addSubview:mapView_]; 
self.view = mapViewCustomer; 

GMSMarker *marker = [[GMSMarker alloc] init]; 
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20); 
marker.title = @"My location"; 
; 
marker.map = mapViewCustomer; 

[marker setIcon:[UIImage imageNamed:@"location1.png"]]; 
} 

,我有一個UIPickerViewviewDidLoad,我試圖把它放在viewWillDisappearviewWillApear,但它不工作:

- (void)viewDidLoad 
{ 
pickerViewCustomer = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 162.0, 320.0, 120.0)]; 
//[pickerViewCustomer setFrame:CGRectMake(0.0, 162.0, 320.0, 120.0)]; 

pickerViewCustomer.hidden = YES; 
pickerViewCustomer.delegate = self; 
pickerViewCustomer.dataSource = self; 
pickerViewCustomer.userInteractionEnabled = NO; 

arrayDistanceFilters = [[NSArray alloc] initWithObjects:@"5km",@"10km",@"50km",@"100km",@"100km",@"100km",@"100km",@"100km",@"100km",@"100km", nil]; 
arrayDistanceValues = [[NSArray alloc] initWithObjects:[NSNumber numberWithFloat:5], [NSNumber numberWithFloat:10],[NSNumber numberWithFloat:50], [NSNumber numberWithFloat:100], nil]; 
[pickerViewCustomer selectRow:1 inComponent:0 animated:NO]; 
[pickerViewCustomer reloadAllComponents]; 
[self.view addSubview:pickerViewCustomer]; 
} 

委託和數據源

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{ 
    return 1; 
} 
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{ 
    return [arrayDistanceFilters count]; 
} 
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{ 
    return [arrayDistanceFilters objectAtIndex:row]; 
} 
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component{ 
    return 40; 
} 
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{ 
} 

但滾動不起作用。我的代碼有什麼問題?

+0

引用下面的鏈接,這是PickerView的解釋的一個例子。 http://www.techotopia.com/index.php/An_iOS_5_iPhone_UIPickerView_Example – Mital

+0

這是一個很好的例子。但這不是我的麻煩。看來,滾動不適用於谷歌地圖。 – user2575045

+0

也許另一個視圖('UIControl')阻止交互? – basvk

回答

0

嘗試在視圖上的其他位置...
我也有一個選擇器,這wasnt滾動,太,然後我移動到的位置(在故事板)的選擇器,它的工作...
關閉自動佈局也幫助!
不滿意,但一個解決方案...