Ios NSArray和开放式详图的适用性
告诉我,我打赌一周,因为点击一个单元格就会打开detailviewIos NSArray和开放式详图的适用性,ios,objective-c,iphone,uitableview,cocoa-touch,Ios,Objective C,Iphone,Uitableview,Cocoa Touch,告诉我,我打赌一周,因为点击一个单元格就会打开detailview NSArray *MyArray = @[@"hi1",@"hi2",@"hi3"]; 我打开故事板,添加一个新的视图,在故事板序列中使用push(不推荐使用)fits id创建链接,但是接下来呢?由于我找不到代码,为初学者创建了一个绑定 PS以防万一,我把我的代码完全传播了 static NSString *cellIdentifier; - (void)locationManager:(CLLocationMan
NSArray *MyArray = @[@"hi1",@"hi2",@"hi3"];
我打开故事板,添加一个新的视图,在故事板序列中使用push(不推荐使用)fits id创建链接,但是接下来呢?由于我找不到代码,为初学者创建了一个绑定
PS以防万一,我把我的代码完全传播了
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.
}
您必须使用segue将数据传递到新视图
这是答案谢谢你的回答,但如何做(告诉我更多)这是答案