Map.After에서 다양한 마커를 플롯하기 위해 NSDictionary
을 사용하고 있습니다. 핀이 플롯되어 있습니다. 사용자 정보를 표시하기 위해 마커에서 콜을 클릭합니다. 이제 콜 아웃을 누르면 marker.title 및 marker.snippet과 같은 세부 정보를 View Controller
에 전달하고 있습니다. 이러한 값을 참조하여 사전에서 다른 세부 정보를 가져 오려고합니다. 다른 뷰 컨트롤러에서 사전에 액세스하기 위해 수행하는 작업입니다. 데이터를 이런 식으로 전달다른 ViewController의 NSDictionary에 액세스하면 null
-(void)fetchMarkerData:(NSString *)typeOfMarker nameOfUser:(NSString *)username
{
NSString *type = typeOfMarker;
NSString *name = username;
NSLog(@"User Type - %@ & Name - %@ ", type, name); // shows name and type
NSLog(@"members dict from map view - %@" , self.membersDetailsDict); // shows null & self.membersDetailsDict is allocated and initialised in viewDidLoad.
if ([type isEqualToString:@"Member"])
{
for (NSDictionary *instance in self.membersDetailsDict)
{
NSString *name= [instance objectForKey:@"pseudo"];
if ([name isEqualToString:name])
{
self.nameLabel.text = name;
self.displayPicture.image =[instance objectForKey:@"avatar"];
self.cityLabel.text = [instance objectForKey:@"pays"];
}
}
}
}
은 : - 당신은 당신이 실제로 거기에 다시 당신이 접근해야 할 때 대신 인스턴스가 두 번째 뷰 컨트롤러에서 membersDict
변수에 액세스하려고하는 것처럼
- (void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(GMSMarker *)marker
{
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard"
bundle: nil];
UserProfileViewController *userProfileViewController = (UserProfileViewController *)[mainStoryboard instantiateViewControllerWithIdentifier:@"UserProfileViewController"];
[userProfileViewController fetchMarkerData:marker.snippet nameOfUser:marker.title];
userProfileViewController.membersDetailsDict = self.membersDict; //passing dictionary also
UINavigationController *nv = [[UINavigationController alloc]initWithRootViewController:userProfileViewController];
[self.revealSideViewController popViewControllerWithNewCenterController:nv animated:YES];
어떻게 컨트롤러를 밀고 데이터를 전달합니까? 해당 코드를 공유하십시오 – Retro
googleMVC는 어떻게 초기화하셨습니까? – Joshua
googleMVC = [[GoogleMapsViewController alloc] init]; ViewDidLoad에서 – icodes