-1

Tell me, I'll bet a week, as clicking on a cell to do so would be opened detailview.

NSArray *MyArray = @[@"hi1",@"hi2",@"hi3"];

I open the storyboard, add a new view, create a link using the push (deprecated) fits id in storyboard segue, but what's next? As I can not find the code for beginners to create a bond.

PS Just in case, I spread my code fully

     static NSString *cellIdentifier;
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
    _startLocation = newLocation;
}
- (void)locationManager:(CLLocationManager *)manager
       didFailWithError:(NSError *)error{/* Не удалось получить информацию о местоположении пользователя. */
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    if ([CLLocationManager locationServicesEnabled]){
        self.myLocationManager = [[CLLocationManager alloc] init];
        self.myLocationManager.delegate = self;
        [self.myLocationManager startUpdatingLocation];
        CLLocation *startLocation = self.myLocationManager.location;
        CLLocation *location2 = [[CLLocation alloc] initWithLatitude:60.050043 longitude:30.345783];
        CLLocation *location3 = [[CLLocation alloc] initWithLatitude:60.040000 longitude:30.323994];
        CLLocation *location4 = [[CLLocation alloc] initWithLatitude:60.037389 longitude:30.322094];
        float betweenDistance=[startLocation distanceFromLocation:location2];
        float betweenDistance3=[startLocation distanceFromLocation:location3];
        float betweenDistance4=[startLocation distanceFromLocation:location4];
        NSArray *stringsArray2 = @[
                                   [NSString stringWithFormat:@"Distance is %f km",betweenDistance/1000],
                                   [NSString stringWithFormat:@"Distance is %f km",betweenDistance3/1000],
                                   [NSString stringWithFormat:@"Distance is %f km", betweenDistance4/1000]
                                   ];
        NSString * combinedStuff = [stringsArray2 componentsJoinedByString:@"\n"];
    [GMSServices provideAPIKey:@"№№№"];
        GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:59.93 longitude:30.35 zoom:9];
        mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
        mapView_.settings.compassButton = YES;
        mapView_.settings.myLocationButton = YES;
        //mapView_.settings.myLocationButton = YES;
        //mapView_.userInteractionEnabled = YES;
        mapView_.frame = CGRectMake(0, 0, 200, 200);
        //mapView_.center = self.view.center;
        [self.scrollView addSubview:mapView_];
        UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 210)];
        self.data = @[
                      [NSString stringWithFormat:@"Distance is %f km",betweenDistance/1000],
                      [NSString stringWithFormat:@"Distance is %f km",betweenDistance3/1000],

                      [NSString stringWithFormat:@"Distance is %f km", betweenDistance4/1000]
                      ];
    cellIdentifier = @"rowCell";
    [self.myTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIdentifier];
    } else {
        /* Геолокационные службы не активизированы.
         Попробуйте исправить ситуацию: например предложите пользователю
         включить геолокационные службы. */
        NSLog(@"Location services are not enabled");
    }
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [self.data count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    cell.textLabel.text = [self.data objectAtIndex:indexPath.row];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"My title" message:[NSString stringWithFormat:@" %@",[self.data objectAtIndex:indexPath.row],[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 210)]] delegate:self cancelButtonTitle:@"Close window" otherButtonTitles:nil];
    [message show];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
user3127658
  • 105
  • 8

1 Answers1

1

You have to pass the data to that new view using the segue

Here is the answer for this Passing Data between View Controllers : from uitableview to a details view controller

Community
  • 1
  • 1
Yousef Abu Sallamah
  • 225
  • 1
  • 2
  • 17