我正在使用MKMapView并在地图上添加了许多注释引脚,大约5-10公里的区域.当我运行应用程序时,我的地图开始缩小以显示整个世界,缩放地图以使引脚适合视图的最佳方法是什么?
编辑: 我最初的想法是使用MKCoordinateRegionMake并从我的注释中计算坐标中心,longitudeDelta和latitudeDelta.我很确定这会起作用,但我只是想检查一下我没有遗漏任何明显的东西.
代码添加,BTW:FGLocation是一个符合的类MKAnnotation
,locationFake是NSMutableArray
这些对象中的一个.欢迎评论....
- (MKCoordinateRegion)regionFromLocations {
CLLocationCoordinate2D upper = [[locationFake objectAtIndex:0] coordinate];
CLLocationCoordinate2D lower = [[locationFake objectAtIndex:0] coordinate];
// FIND LIMITS
for(FGLocation *eachLocation in locationFake) {
if([eachLocation coordinate].latitude > upper.latitude) upper.latitude = [eachLocation coordinate].latitude;
if([eachLocation coordinate].latitude < lower.latitude) lower.latitude = [eachLocation coordinate].latitude;
if([eachLocation coordinate].longitude > upper.longitude) upper.longitude = [eachLocation coordinate].longitude;
if([eachLocation coordinate].longitude < lower.longitude) lower.longitude = [eachLocation coordinate].longitude;
}
// FIND REGION
MKCoordinateSpan locationSpan;
locationSpan.latitudeDelta = upper.latitude - lower.latitude;
locationSpan.longitudeDelta = upper.longitude - lower.longitude;
CLLocationCoordinate2D …
Run Code Online (Sandbox Code Playgroud) 我UITableView
在IB中添加了一个并设置了"委托"和"数据源",一切运行良好.我接下来要做的是更改分隔符颜色,但我能找到的唯一方法是将方法添加到其中一个委托回调中,是否有更好的地方我应该这样做?
我目前没有这个,但我想也许我需要从我的控制器添加一个"iVar",我可以链接到UITableView
IB中,然后设置分隔符颜色viewDidload
?
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView setSeparatorColor:[UIColor blackColor]];
return 65;
}
Run Code Online (Sandbox Code Playgroud) 通常在a的每个选项卡上UITabBar
都有一个小图像和一个命名选项卡的标题.图像位于标签顶部/居中,以容纳下方的标题.我的问题是:如果你想让tabBar只有一个图像而没有标题,那么有一种方法可以将图像向下移动,使其在标签内更好地居中吗?
我目前正在使用(见下文):
[tabBarItem setFinishedSelectedImage:tabSelected withFinishedUnselectedImage:tabUnselected];
Run Code Online (Sandbox Code Playgroud)
但是我更喜欢使用没有标题的较大图像,此时如果我使图像大于约70像素@ 2x它开始从顶部开始边缘,UITabBar
同时在底部留下大量未使用的空间.
如果我有一个设置为200.0的NSTimeInterval,有没有办法将其转换为00:03:20,我想我可以用它初始化NSDate然后使用NSDateFormatter使用HH:mm:ss.我的问题是,有一个快速的方法来做到这一点,还是我必须自己分解数字并使用[NSString stringWithFormat: %02d:%02d:%02d, myHour, myMin, mySec]
?
有没有办法使用iTunes连接或API来检查自发布以来特定应用程序的应用程序销售总数.我只是很好奇,因为iPhone上的ITC似乎只显示26周显示总数,所以它错过了前20周以上.(该应用程序已经出去约50周).
我想看看发布到现在,总销售额= 4067这可能吗?
我试图澄清一些关于实施的问题copyWithZone:
,任何人都可以评论以下内容......
// 001: Crime is a subclass of NSObject.
- (id)copyWithZone:(NSZone *)zone {
Crime *newCrime = [[[self class] allocWithZone:zone] init];
if(newCrime) {
[newCrime setMonth:[self month]];
[newCrime setCategory:[self category]];
[newCrime setCoordinate:[self coordinate]];
[newCrime setLocationName:[self locationName]];
[newCrime setTitle:[self title]];
[newCrime setSubtitle:[self subtitle]];
}
return newCrime;
}
// 002: Crime is not a subclass of NSObject.
- (id)copyWithZone:(NSZone *)zone {
Crime *newCrime = [super copyWithZone:zone];
[newCrime setMonth:[self month]];
[newCrime setCategory:[self category]];
[newCrime setCoordinate:[self coordinate]];
[newCrime setLocationName:[self locationName]];
[newCrime setTitle:[self title]];
[newCrime …
Run Code Online (Sandbox Code Playgroud) 在一个或一个上使用copy
和之间有什么区别?mutableCopy
NSArray
NSMutableArray
这是我的理解; 这是对的吗?
// ** NSArray **
NSArray *myArray_imu = [NSArray arrayWithObjects:@"abc", @"def", nil];
// No copy, increments retain count, result is immutable
NSArray *myArray_imuCopy = [myArray_imu copy];
// Copys object, result is mutable
NSArray *myArray_imuMuta = [myArray_imu mutableCopy];
// Both must be released later
Run Code Online (Sandbox Code Playgroud)
// ** NSMutableArray **
NSMutableArray *myArray_mut = [NSMutableArray arrayWithObjects:@"A", @"B", nil];
// Copys object, result is immutable
NSMutableArray *myArray_mutCopy = [myArray_mut copy];
// Copys object, result is mutable
NSMutableArray *myArray_mutMuta …
Run Code Online (Sandbox Code Playgroud) 我有一个GPS坐标(纬度,经度),我很快就想在显示该位置的MKMapView上放置一个引脚.一切都运行得很好,但因为我只需要一个没有标注的单个引脚是否有更快的方法来做到这一点,或者我在下面需要做什么?
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id < MKAnnotation >)annotation {
MKPinAnnotationView *pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"DETAILPIN_ID"];
[pinView setAnimatesDrop:YES];
[pinView setCanShowCallout:NO];
return pinView;
}
Run Code Online (Sandbox Code Playgroud)
注意:我不需要检查可重复使用的注释视图,因为我只使用引脚在详细视图中显示位置(在下次请求详细视图时销毁并重新创建).
我有一个UITableView
与cells
被动态地更新.一切正常,除了tableview.reload
调用时(见下文)刷新cells
表中我希望表滚动到底部以显示新条目.
- (void)reloadTable:(NSNotification *)notification {
NSLog(@"RELOAD TABLE ...");
[customTableView reloadData];
// Scroll to bottom of UITable here ....
}
Run Code Online (Sandbox Code Playgroud)
我打算使用scrollToRowAtIndexPath:atScrollPosition:animated:
但后来注意到我无法访问indexPath
.
有谁知道怎么做,或者delegate
我可以使用的回调?
如果我为一个对象创建一个自定义initWith,我实际上是否包含我想要覆盖init的代码?
-(id) init {
self = [super init];
if (self) {
NSLog(@"_init: %@", self);
}
return(self);
}
Run Code Online (Sandbox Code Playgroud)
例如
-(id) initWithX:(int) inPosX andY:(int) inPosY {
self = [super init];
if(self) {
NSLog(@"_init: %@", self);
posX = inPosX;
posY = inPosY;
}
return(self);
}
Run Code Online (Sandbox Code Playgroud)
加里
cocoa-touch ×8
objective-c ×8
iphone ×7
ios ×2
mkmapview ×2
cocoa ×1
copywithzone ×1
nsarray ×1
nscopying ×1
uitabbar ×1
uitabbaritem ×1
uitableview ×1