小编Ale*_*iop的帖子

在iOS 6中填充Tableview单元格

我已经尝试搜索一些关于如何填充表视图的教程,但我发现的只是旧的和过时的视频.我尝试从稍微更新的那个做,但它不起作用.我有

- (void)viewDidLoad
{
    [super viewDidLoad];
   [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
    [chemarray addObject:@"2"];
    [chemarray addObject:@"test"];
    [chemarray addObject:@"3"];
    [chemarray addObject:@"science"];  
}
Run Code Online (Sandbox Code Playgroud)

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [chemarray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:    (NSIndexPath *)indexPath
{

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"     forIndexPath:indexPath];

     cell.textLabel.text = [chemarray objectAtIndex:indexPath.row];
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

根据本教程,在运行时,它应该显示我的数组中的项目,但对我来说,它不会!有谁知道如何解决这一问题?

objective-c uitableview

16
推荐指数
1
解决办法
2万
查看次数

Google Maps API:获取当前位置iOS的坐标

我目前正在我的项目中使用Google Maps API.我正在尝试将默认相机/缩放设置为用户位置.我这样做:

@implementation ViewController{

GMSMapView *mapView_;

}
@synthesize currentLatitude,currentLongitude;

- (void)viewDidLoad
{
[super viewDidLoad];
mapView_.settings.myLocationButton = YES;
mapView_.myLocationEnabled = YES;


}
- (void)loadView{

CLLocation *myLocation = mapView_.myLocation;

GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(myLocation.coordinate.latitude, myLocation.coordinate.longitude);
marker.title = @"Current Location";
marker.map = mapView_;
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:myLocation.coordinate.latitude
                                                        longitude:myLocation.coordinate.longitude
                                                             zoom:6];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];

self.view = mapView_;
   NSLog(@"%f, %f", myLocation.coordinate.latitude, myLocation.coordinate.longitude);

}
Run Code Online (Sandbox Code Playgroud)

但是,它不起作用,因为当我这样做

NSLog(@"%f, %f", myLocation.coordinate.latitude, myLocation.coordinate.longitude);
Run Code Online (Sandbox Code Playgroud)

它返回0,0,并且它不给出当前位置坐标.如何正确获取用户的坐标?

location google-maps objective-c ios google-maps-sdk-ios

9
推荐指数
2
解决办法
4万
查看次数

刷新Google Maps iOS中的内容

我目前正在使用iOS版Google Maps API。我已经在地图上绘制了标记,但是一旦用户从另一个类中输入了新数据,我不知道如何“刷新”(删除标记并重新绘制新标记)标记。我尝试像这样回忆地图视图类:

这是用户输入新数据时执行的另一个类(GetInfoViewController)中的代码

MapViewController *mapVC = [[MapViewController alloc]init];
[mapVC resetMap];
Run Code Online (Sandbox Code Playgroud)

这是MapViewController内部的内容

- (void)viewDidLoad
{
    [super viewDidLoad];
    mapView.myLocationEnabled = YES;
    mapView.settings.myLocationButton = YES;
    getpos = [[NSMutableArray alloc]init];

}

- (void)loadView {

    lat = [[NSMutableArray alloc]init];
    lng = [[NSMutableArray alloc]init];
    markers = [[NSMutableArray alloc]init];
    locationManager = [[CLLocationManager alloc] init];
    locationManager.distanceFilter = kCLDistanceFilterNone;
    locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m


    [locationManager startUpdatingLocation];

    GMSCameraPosition *camera = [GMSCameraPosition   cameraWithLatitude:locationManager.location.coordinate.latitude
                                                            longitude:locationManager.location.coordinate.longitude                                                                 zoom:13.2];

    mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
    mapView.delegate = self;

    self.view = mapView;
    [mapView clear];
    [self …
Run Code Online (Sandbox Code Playgroud)

google-maps objective-c google-maps-markers ios

5
推荐指数
1
解决办法
6710
查看次数

向下滚动并推送新的viewcontroler后,UIScrollview将内容向上移动

我在uiscrollview上找出这个问题很困难.单击按钮将新视图控制器推入屏幕后,我的uiscrollview中的内容会向上移动,然后返回到原始视图控制器.请注意scrollview顶部的更改方式.

在此输入图像描述 在此输入图像描述

这是scrollView的代码

- (void)viewDidLoad{
    [super viewDidLoad];

    [scroll setScrollEnabled:YES];
    [scroll setContentSize:CGSizeMake(923, 934)];
    [self.view addSubview:scroll];
}
Run Code Online (Sandbox Code Playgroud)

objective-c uiscrollview ios

5
推荐指数
1
解决办法
3445
查看次数

如何使用UIButton更改容器的内容?

我试图将容器内的嵌入内容从tableviewcontroller更改为map.我试过搜索它,但所有的问题都与tabview有关,我没有这样做.我该如何开始这个过程?

我也尝试过

- (IBAction)changer:(id)sender {
    UIViewController *viewController1 = [self.storyboard instantiateViewControllerWithIdentifier:@"vc1"];
    container.view = viewController1;
}
Run Code Online (Sandbox Code Playgroud)

但这不起作用

objective-c ios

2
推荐指数
1
解决办法
1111
查看次数

Yelp API ios获得更大的图像

我目前正在为我的项目使用Yelp API,我需要获取企业的图像作为背景,显示在UIImageView中.但是,所有图片都比获得的图片太小,因此背景模糊.我使用此代码获取当前的业务图像:

[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[businessDict objectForKey:@"image_url"]]]];
Run Code Online (Sandbox Code Playgroud)

反正有没有获得更大的图像?

objective-c uiimageview uiimage ios yelp

2
推荐指数
1
解决办法
1503
查看次数

replaceCharactersInRange不按预期工作?

我有一个NSMutableString,它包含字符串"我有∞小时和∞最小备用." 我试图用"0"替换第一个∞

NSMutableString *timeString = [NSMutableString stringWithString:@"And I have ? Hours and ? Min to spare."];
NSLog(@"%@",timeString);
[timeString replaceCharactersInRange:NSMakeRange(11,12) withString:@"0"];
NSLog(@"%@",timeString);
Run Code Online (Sandbox Code Playgroud)

但是,它不是仅替换第一个∞,而是替换短语"∞小时"和

这是在控制台中打印出来的内容:

And I have ? Hours and ? Min to spare.
And I have 0? Min to spare.
Run Code Online (Sandbox Code Playgroud)

我不明白为什么删除超出指定范围的字符.

objective-c nsmutablestring ios

0
推荐指数
2
解决办法
1225
查看次数