这是我的代码,我使用了谷歌地图和UIPickerView
:
-(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"]];
}
我有一个UIPickerView
in viewDidLoad
,我试过把它戴上,viewWillDisappear
但viewWillApear
它不起作用:
- (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{
}
但是滚动不起作用。我的代码有什么问题?