- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 map View 上有一个搜索栏,允许用户搜索名称(注释标题)或地址(注释副标题)。如果用户输入整个标题或副标题,我就可以正常工作,但我试图让用户只需要输入部分名称或地址。例如,有一个 Cates Farm 的注释。我希望用户能够只输入 cates 并让它找到注释。我设置的方式不仅可以找到数组中的最后一个标题,而且运行速度很慢。有什么帮助或建议吗?
这是我的代码。我注释掉的行来自用户输入整个标题或副标题时我可以正常工作的地方。
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
id<MKAnnotation> ann;
NSString *searchText = [searchBar text];
NSString *annTitle = ann.title;
NSString *annSubtitle = ann.subtitle;
NSRange titleRange = [annTitle rangeOfString:searchText options:NSCaseInsensitiveSearch];
NSRange subtitleRange = [annSubtitle rangeOfString:searchText options:NSCaseInsensitiveSearch];
for (int i = 0; i < [marketLocations count]; i++)
{
for (ann in marketLocations)
{
// if ([ann.title isEqualToString:[searchBar text]])
if (titleRange.location != NSNotFound)
{
[worldView selectAnnotation:ann animated:YES];
}
// else if ([ann.subtitle isEqualToString:[searchBar text]])
else if (subtitleRange.location != NSNotFound)
{
[worldView selectAnnotation:ann animated:YES];
}
}
}
[searchBar resignFirstResponder];
}
编辑:
我现在正在尝试实现indexOfObjectPassingTest方法来完成我想要的,但我似乎不知道如何实现它来满足我的需求。
以下是更好的上下文的所有代码:
//
// RSFM.m
// KFBNewsroom
#import "RSFM.h"
#import "AnnotationDetailView.h"
#import "MapSettings.h"
@interface RSFM ()
@end
@implementation RSFM
{
}
@synthesize centerCoordinate, coordinate, title, subtitle, marketAnnotation, location, marketLocations;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
self.title = NSLocalizedString(@"Farm Markets", @"Farm Markets");
// Create location manager object
locationManager = [[CLLocationManager alloc]init];
[locationManager setDelegate:self];
// And we want it to be as accurate as possible regardless of how much time/power it takes
[locationManager setDesiredAccuracy:kCLLocationAccuracyThreeKilometers];
// Tell our manager to start looking for its location immediately
// [locationManager startUpdatingLocation];
}
return self;
}
- (void)findLocation
{
[locationManager startUpdatingLocation];
[activityIndicator startAnimating];
[locationManager stopUpdatingLocation];
}
- (void)foundLocation:(CLLocation *)loc
{
// CLLocationCoordinate2D coord = [loc coordinate];
CLLocationCoordinate2D coord2 = coordinate;
coord2.latitude = 37.833333;
coord2.longitude = -85.833333;
// Zoom the region to this location
// MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coord, 400000, 400000);
// MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coord, 500, 500);
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coord2, 350000, 350000);
[worldView setRegion:region animated:YES];
// Reset the UI
// [locationTitleField setText:@""];
[activityIndicator stopAnimating];
// [locationTitleField setHidden:NO];
[locationManager stopUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"%@", newLocation);
// How many seconds ago was this new location created?
NSTimeInterval t = [[newLocation timestamp]timeIntervalSinceNow];
// CLLocationManagers will return the last found location of the device first, you don't want that data in this case.
// If this location was made more than 3 minutes ago, ignore it.
if (t < -180)
{
// this is cached data, you don't want it, keep looking
return;
}
[self foundLocation:newLocation];
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"Could not find location: %@", error);
}
- (void)dealloc
{
// Tell the location manager to stop sending us messages
[locationManager setDelegate:nil];
}
- (MKAnnotationView*)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
// If it's the user location, return nil
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
// Try to dequeue an existing pin view first
static NSString *annotationIdentifier = @"AnnotationIdentifier";
MKPinAnnotationView *pinView = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:annotationIdentifier];
pinView.animatesDrop = NO;
pinView.pinColor = MKPinAnnotationColorRed;
pinView.canShowCallout = YES;
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton setTitle:annotation.title forState:UIControlStateNormal];
pinView.rightCalloutAccessoryView = rightButton;
return pinView;
}
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
AnnotationDetailView *detail = [[AnnotationDetailView alloc] initWithNibName:nil bundle:nil];
id<MKAnnotation> ann = [mapView.selectedAnnotations objectAtIndex:0];
ann = view.annotation;
CLLocationCoordinate2D annCoord;
annCoord.latitude = ann.coordinate.latitude;
annCoord.longitude = ann.coordinate.longitude;
detail.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
NSLog(@"%@", ann.title);
NSLog(@"%@", ann.subtitle);
detail.annTitle = ann.title;
detail.annSub = ann.subtitle;
detail.latText = [NSString localizedStringWithFormat:@"%f",annCoord.latitude];
detail.longText = [NSString localizedStringWithFormat:@"%f", annCoord.longitude];
[self.navigationController pushViewController:detail animated:YES];
}
- (void)viewDidLoad
{
[locationManager startUpdatingLocation];
[worldView setShowsUserLocation:YES];
[locationManager stopUpdatingLocation];
UISearchBar *searchBar = [[UISearchBar alloc] init];
searchBar.frame = CGRectMake(0, 0, 320,44);
searchBar.showsBookmarkButton = NO;
searchBar.showsCancelButton = YES;
searchBar.delegate = self;
[self.view addSubview:searchBar];
// NSMutableArray *marketLocations = [[NSMutableArray alloc]init];
marketLocations = [[NSMutableArray alloc]init];
NSMutableArray *lat = [[NSMutableArray alloc]initWithObjects:@"37.7867266", @"37.0703517", @"37.1610806", @"37.318367", @"37.3559204", @"37.4154066", @"37.4757622", @"37.7450252", @"37.6318978", @"37.0716803", @"36.7333486", @"36.8637044", @"36.9181305", @"36.8736459", @"36.93253", @"37.0436832", @"37.1516087", @"36.712052", @"36.8082663", @"37.1799935", @"37.8928444", @"37.7488563", @"37.499522", @"37.5882222", @"37.4991846", @"37.5392879", @"37.3721288", @"37.1922315", @"37.102841", @"36.9813651", @"36.660251", @"37.1301316", @"37.1734765", @"37.0505279", @"36.9179492", @"37.2742692", @"37.2116415", @"37.2412938", @"37.2696374", @"37.5464147", @"37.5693561", @"37.7146149", @"37.7647463", @"37.635366", @"37.6417237", @"37.8515069", @"37.6840096", @"37.6000712", @"37.6655401", @"37.6668541", @"37.710869", @"37.7101039", @"37.8721419", @"37.9711379", @"38.0069215", @"38.135998", @"38.105713", @"38.160352", @"38.223825", @"38.188871", @"38.235703", @"38.3586935", @"38.3069755", @"38.6109009", @"38.3600355", @"38.4004693", @"38.5997367", @"38.6414842", @"38.5741722", @"38.1756649", @"38.2686626", @"38.4329612", @"38.673506", @"38.1916673", @"38.2265882", @"38.7363261", @"38.9734399", @"38.977975", @"38.8985392", @"38.903505", @"38.7418795", @"38.5102869", @"38.4260502", @"38.2687025", @"38.2097987", @"38.2074495", @"38.1356551", @"38.1245065", @"38.036634", @"37.9976315", @"37.7785109", @"37.9324058", @"37.9442351", @"37.9631701", @"37.9572905", @"38.0575357", @"37.8184352", @"37.920693", @"37.6256607", @"37.125056", @"37.911885", @"38.4948355", @"38.5124872", @"38.359333", @"37.5453841", @"36.7641572", @"37.5846472", nil];
NSMutableArray *lon = [[NSMutableArray alloc]initWithObjects:@"-87.608209", @"-88.1237899", @"-87.9148629", @"-87.5074402", @"-87.5448032", @"-87.8003148", @"-87.9515986", @"-87.9061638", @"-87.1148574", @"-87.3008418", @"-87.5661605", @"-87.290597", @"-86.8270899", @"-86.6544847", @"-86.490067", @"-86.4558939", @"-86.2038694", @"-86.3287002", @"-85.9428197", @"-85.8312895", @"-86.2219159", @"-85.8042332", @"-85.8837926", @"-85.6896553", @"-85.6185338", @"-85.3974197", @"-85.3594512", @"-85.5906947", @"-85.3063504", @"-85.060269", @"-85.212777", @"-84.8720139", @"-84.8137247", @"-84.5698918", @"-84.1312625", @"-84.4614493", @"-84.4802606", @"-84.4223536", @"-84.6410206", @"-84.4564877", @"-84.2884479", @"-84.4089207", @"-84.3655048", @"-84.5597937", @"-84.7606165", @"-84.8732843", @"-85.2055835", @"-85.0401771", @"-85.248661", @"-85.1834814", @"-85.261238", @"-85.259706", @"-85.3155742", @"-85.689489", @"-85.8210816", @"-85.503977", @"-85.654787", @"-85.855705", @"-85.592095", @"-85.520966", @"-85.156767", @"-85.1048516", @"-85.1471807", @"-85.1186233", @"-85.5047839", @"-85.3788328", @"-85.3060421", @"-85.3237933", @"-85.2994716", @"-84.8965549", @"-84.6066196", @"-84.8581488", @"-84.8477954", @"-84.541101", @"-84.5685446", @"-84.6280011", @"-84.721179", @"-84.749313", @"-84.6090422", @"-84.441984", @"-84.0662604", @"-83.8971076", @"-83.8566679", @"-84.2433673", @"-84.2529869", @"-84.4785665", @"-84.3652534", @"-84.3541421", @"-84.551631", @"-84.7000274", @"-84.5389521", @"-84.3865064", @"-84.2261198", @"-84.2162117", @"-83.793939", @"-83.9017386", @"-84.0842092", @"-83.2513743", @"-83.5944371", @"-82.787241", @"-82.748201", @"-82.8310584", @"-82.7304443", @"-83.5611122", @"-84.3922468", @"-86.8666113",@"-87.2933751", nil];
NSMutableArray *title1 = [[NSMutableArray alloc]initWithObjects:@"Cates Farm", @"Broadbent B & B Foods", @"Cayce's Pumpkin Patch", @"Metcalfe Landscaping", @"Brumfield Farm Market", @"Dogwood Valley Farm", @"Country Fresh Meats & Farmers Market", @"Jim David Meats", @"Trunnell's Farm Market", @"Lovell's Orchard & Farm Market", @"Zook's Produce", @"The Country Barn", @"Poore's Nursery & Farms", @"Just Piddlin Farm", @"Chaney's Dairy Barn & Restaurant", @"Jackson's Orchard & Nursery, Inc.", @"Mammoth Cave Transplants", @"Habegger's Amish Market", @"Kenny's Farmhouse Cheese", @"Dennison's Roadside Market", @"Roberts Family Farm", @"Wooden Farm", @"Jordan Greenhouses", @"Lee's Garden Center, Florist & Gift Shop", @"Hinton's Orchard & Farm Market", @"Serenity Farm Alpacas", @"Burton's Nursery & Garden Center", @"Davis Family Farms", @"Heavenly Haven Farm", @"French Valley Farms", @"Cravens Greenhouse", @"Haney's Appledale Farm", @"Hettmansperger's Greenhouse", @"D & F Farms", @"Double Hart Farm", @"Owens Garden Center", @"Hail's Farm", @"Sinking Valley Vineyard & Winery, Inc.", @"Todd's Greenhouse & Florist, LLC", @"McQuerry's Family Farm-Herbs-N-Heirlooms", @"Berea College Farm & Gardens", @"Acres of Land Winery & Restaurant", @"Baldwin Farms", @"Wonder of Life Farm", @"Chateau du Vieux Corbeau Winery/Old Crow Farm Winery", @"Devine's Farm & Corn Maze", @"Flaggy Meadow Fiber Works & Sunshine Alpacas of Kentucky", @"Williams Country Market", @"Serano Alpacas & Yarns", @"1851 Historic Maple Hill Manor B & B, Alpaca & Llama Farm, & Fiber Farm Store", @"Campbell Farm Wool Art Center", @"St. Catharine Farm", @"Capture Your Heart Alpacas", @"Ridgeview Greenhouse & Nursery", @"Country Corner Greenhouse & Nursery, Inc", @"Sunny Acres Farm", @"Morrison's Greenhouses", @"George Gagel Farm Market, LLC", @"Thieneman's Herbs & Perennials", @"Tower View Farm & Nursery", @"Gallrein Farms", @"Sweet Home Spun in the Low Dutch Meetinghouse", @"Mulberry Orchard, LLC", @"Gregory Farms", @"Foxhollow Farm Store", @"Sherwood Acres Beef", @"Bray Orchard & Roadside Market", @"Callis Orchards", @"Bray Fruit", @"Wilson's Nursery", @"Triple J Farm", @"Ayres Family Orchard", @"Michels Family Farm", @"Amerson Farm", @"Bi-Water Farm & Greenhouse", @"Alpine Hills Dairy Tour/Country Pumpkins", @"Blue Ribbon Market", @"Eagle Bend Alpacas Fiber & Gift Shoppe", @"Benton Farms", @"Redman's Farm",@"The Greenhouse in Gertrude", @"Croppers Greenhouse & Nursery", @"McLean's Aerofresh Fruit", @"Julie's Pumpkins", @"Reed Valley Orchard", @"Evans Orchard & Cider Mill", @"Kentucky Green Market", @"Antioch Daylily Garden", @"Golden Apple Fruit Market", @"Boyd Orchards", @"Serenity Hill Fiber & Living History Farm", @"Kelley Farms", @"Beech Springs Farm Market", @"Yuletide Tree Farm & Nursery", @"Townsend's Sorghum Mill and Farm Market", @"Bramble Ridge Orchard", @"C2H2 Farm Market", @"Fannin's Vegetables", @"Country Garden Greenhouse", @"Golden Apple Fruit Market", @"Black Barn Produce, LLC", @"Imel's Greenhouse", @"Feathered Wing Farm Market", @"Hutton-Loyd Tree Farm", @"Halcomb's Knob, LLC", @"Martin Farms", @"Happy Hollow Farms",nil];
NSMutableArray *subtitle1 = [[NSMutableArray alloc]initWithObjects:@"Hwy 425 Henderson, KY 42420", @"257 Mary Blue Road Kuttawa, KY 42055", @"153 Farmersville Road Princeton, KY 42445", @"410 Princeton Road Madisonville, KY 42431", @"3320 Nebo Road Madisonville, KY 42431", @"4551 State Route 109N Clay, KY 42404", @"9355 US Hwy 60 W Sturgis, KY 42459",@"350 T. Frank Wathen Rd. Uniontown, KY 42461", @"9255 Hwy 431 Utica, KY 42376", @"22850 Coal Creek Road Hopkinsville, KY 42240", @"Intersection of KY107 & KY117 Herndon, KY 42240", @"112 Britmart Road Elkton, KY 42220", @"5486 Morgantown Road Russellville, KY 42276", @"10830 S. Morgantown Rd. Woodburn, KY 42170", @"9191 Nashville Road, Bowling Green, KY 42101", @"1280 Slim Island Road Bowling Green, KY 42101", @"5394 Brownsville Road Brownsville, KY 42210", @"945 Perrytown Road Scottsville, KY 42164", @"2033 Thomerson Park Road Austin, KY 42123", @"5824 S. Jackson Hwy. Horse Cave, KY 42749", @"125 Kennedy Road Guston, KY 40142", @"1869 Wooden Lane Elizabethtown, KY 42701", @"13287 Dixie Highway Upton, KY 42784", @"1918 Bardstown Road Hodgenville, KY 42748", @"8631 Campbellsville Road Hodgenville, KY 42748", @"1380 Frogg Lane Raywick, KY 40060", @"2212 Saloma Road Campbellsville, KY 42718", @"313 Hwy 1464 Greensburg, KY 42743", @"230 Heavenly Lane Columbia, KY 42728", @"1842 N. Main St. Jamestown, KY 42629", @"500 Cedar Hill Road Albany, KY 42602", @"8350 West 80 Nancy, KY 42544-8756", @"3917 N. Hwy 837 Science Hill, KY 42553", @"755 Elihu Rush Branch Road Somerset, KY 42501", @"6550 Cumberland Falls Road Corbin, KY 40701", @"735 Latham Road Somerset, KY 42503", @"Hwy 461, at 3 mile marker Somerset, KY 42503", @"1300 Plato-Vanhook Road Somerset, KY 42503", @"35 Skyline Drive Eubank, KY 42567", @"169 Pine Hill Road Paint Lick, KY 40461", @"230 N. Main St. Berea, KY 40404", @"2285 Barnes Mill Road Richmond, KY 40475", @"1113 Tates Creek Road Richmond, KY 40475", @"686 Buckeye Road Lancaster, KY 40444", @"471 Stanford Avenue Danville, KY 40422-1927", @"623 Talmage-Mayo Road Harrodsburg, KY 40330", @"2110 Mackville Road Springfield, KY 40069", @"4189 Craintown Rd. Gravel Switch, KY 40328", @"1805 Booker Road Springfield, KY 40069", @"2941 Perryville Road, US 150 Springfield, KY 40069", @"2888 Bardstown Road Springfield, KY 40069", @"2645 Bardstown Road Springfield, KY 40061", @"9430 Bloomfield Road Bloomfield, KY 40008", @"460 Buffalo Run Road Shepherdsville, KY 40165", @"4877 Hwy 44E Shepherdsville, KY 40165", @"6516 Echo Trail Jeffersontown, KY 40299", @"5613 Cooper Chapel Road Louisville, KY 40229", @"2400 Lower Hunters Trace Louisville, KY 40216", @"9120 Blowing Tree Road Louisville, KY 40220", @"12523 Taylorsville Road Jeffersontown, KY 40299", @"1029 Vigo Road Shelbyville, KY 40065", @"6805 Castle Hwy. Pleasureville, KY 40057", @"1330 Mulberry Pike Shelbyville, KY 40065", @"985 Vance Road Turners Station, KY 40075", @"8905 Hwy 329 Crestwood, KY 40014", @"215 Parker Drive LaGrange, KY 40031", @"2580 Hwy 42 W. Bedford, KY 40006", @"3721 Hwy 421 N Bedford, KY 40006", @"1660 Highway 421 N Bedford, KY 40006", @"3690 East-West Connector (Rte 676) Frankfort, KY 40601", @"2287 Long Lick Road Georgetown, KY 40324", @"525 Wilson Lane Owenton, KY 40359", @"4275 Hwy 1316 Sparta, KY 41086", @"130 McClelland Circle Georgetown, KY 40324", @"877 Cincinnati Road Georgetown, KY 40324", @"2165 Sherman Mount Zion Rd. Dry Ridge, KY 41035", @"8707 Camp Ernst Road Union, KY 41091", @"7812 East Bend Road Burlington, KY 41005", @"11896 Old Lexington Pike Walton, KY 41094", @"12449 Decoursey Pike Morning View, KY 41063", @"3246 Augusta-Berlin Road Brooksville, KY 41004", @"5350 Raymond Road May's Lick, KY 41055", @"4085 Ewing Road Ewing, KY 41039", @"1069 Ruddles Mill Road Paris, KY 40361", @"239 Lail Lane Paris, KY 40361", @"180 Stone Road Georgetown, KY 40324", @"5751 Lexington Rd. Lexington, KY 40511", @"2231 Houston Antioch Road Lexington, KY 40516", @"1801 Alexandria Drive Lexington, KY 40504", @"1396 Pinckard Pike Versailles, KY 40383", @"1371 Beverly Lane Nicholasville, KY 40356", @"6483 Old Richmond Road Lexington, KY 40515", @"4776 Old Boonesboro Road Winchester, KY 40391", @"3925 Old Boonesboro Road Winchester, KY 40391", @"11620 Main Street Jeffersonville, KY 40337", @"2726 Osborne Road Mt. Sterling, KY 40353", @"1098 Harris Ferry Road Irvine, KY 40336", @"2140 Hwy 460W West Liberty, KY 41472", @"99 Union Road Beattyville, KY 41311", @"1523 Hwy 119 North Whitesburg, KY 41815", @"52 KY Route 3224 River, KY 41254", @"2836 State Route 1 Greenup, KY 41144", @"45 Katherine Lane Greenup, KY 41144", @"1483 Big Run Road Wallingford, KY 41093", @"430 Wallacetown Road Paint Lick, KY 40461", @"5595 Nashville Road Russellville, KY 42276", @"9730 KY 136W Calhoun, KY 42327", nil];
NSLog(@" Lat Count: %lu", (unsigned long)[lat count]);
NSLog(@" Long Count: %lu", (unsigned long)[lon count]);
NSLog(@" Title Count: %lu", (unsigned long)[title1 count]);
NSLog(@" Subtitle Count: %lu", (unsigned long)[subtitle1 count]);
// CLLocationCoordinate2D location;
// MKPointAnnotation *marketAnnotation;
for (int x = 0; x < [lat count]; x++)
{
marketAnnotation = [[MKPointAnnotation alloc]init];
location.latitude = [[lat objectAtIndex:x]floatValue];
location.longitude = [[lon objectAtIndex:x]floatValue];
marketAnnotation.coordinate = location;
marketAnnotation.title = [title1 objectAtIndex:x];
marketAnnotation.subtitle = [subtitle1 objectAtIndex:x];
[marketLocations addObject:marketAnnotation];
}
[worldView addAnnotations:marketLocations];
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
[searchBar resignFirstResponder];
}
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{
searchBar.autocapitalizationType = UITextAutocapitalizationTypeWords;
}
- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
{
NSLog(@"searchBarTextDidEndEditing:");
[searchBar resignFirstResponder];
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
id<MKAnnotation> ann;
NSString *searchText = [searchBar text];
NSString *annTitle = ann.title;
NSString *annSubtitle = ann.subtitle;
// NSString *marketTitle = marketAnnotation.title;
// NSString *marketSubtitle = marketAnnotation.subtitle;
// NSRange titleRange = [marketTitle rangeOfString:searchText options:NSCaseInsensitiveSearch];
// NSRange subtitleRange = [marketSubtitle rangeOfString:searchText options:NSCaseInsensitiveSearch];
NSRange titleRange = [annTitle rangeOfString:searchText options:NSCaseInsensitiveSearch];
NSRange subtitleRange = [annSubtitle rangeOfString:searchText options:NSCaseInsensitiveSearch];
for (int i = 0; i < [marketLocations count]; i++)
{
for (ann in marketLocations)
{
// if ([ann.title isEqualToString:[searchBar text]])
if (titleRange.location != NSNotFound)
{
[worldView selectAnnotation:ann animated:YES];
}
// else if ([ann.subtitle isEqualToString:[searchBar text]])
else if (subtitleRange.location != NSNotFound)
{
[worldView selectAnnotation:ann animated:YES];
}
}
}
[searchBar resignFirstResponder];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
CLLocationCoordinate2D coord2 = coordinate;
coord2.latitude = 37.833333;
coord2.longitude = -85.833333;
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coord2, 350000, 350000);
[worldView setRegion:region animated:YES];
[locationManager stopUpdatingLocation];
locationManager.delegate = nil;
}
- (IBAction)selectSegmentControl
{
int segmentTouched = [mapVarieties selectedSegmentIndex];
NSString *segmentName = [mapVarieties titleForSegmentAtIndex:segmentTouched];
if ([segmentName isEqualToString:@"Street"])
{
[worldView setMapType:MKMapTypeStandard];
}
if ([segmentName isEqualToString:@"Satellite"])
{
[worldView setMapType:MKMapTypeSatellite];
}
if ([segmentName isEqualToString:@"Hybrid"])
{
[worldView setMapType:MKMapTypeHybrid];
}
}
@end
最佳答案
您正在 annTitle 中找到 searchText 的范围(即位置),annTitle 是从 ann 对象构建的,而 ann 对象是从……没有构建的(函数的第 1 行)。
将 rangeOfString
行移至循环中,以便您在 marketLocations
中的每个 ann
内检查 searchText
关于ios - 检查字符串是否与另一个字符串部分匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16577922/
IO 设备如何知道属于它的内存中的值在memory mapped IO 中发生了变化? ? 例如,假设内存地址 0 专用于保存 VGA 设备的背景颜色。当我们更改 memory[0] 中的值时,VGA
我目前正在开发一个使用Facebook sdk登录(通过FBLoginView)的iOS应用。 一切正常,除了那些拥有较旧版本的facebook的人。 当他们按下“使用Facebook登录”按钮时,他
假设我有: this - is an - example - with some - dashesNSRange将使用`rangeOfString:@“-”拾取“-”的第一个实例,但是如果我只想要最后
Card.io SDK提供以下详细信息: 卡号,有效期,月份,年份,CVV和邮政编码。 如何从此SDK获取国家名称。 - (void)userDidProvideCreditCardInfo:(Car
iOS 应用程序如何从网络服务下载图片并在安装过程中将它们安装到用户的 iOS 设备上?可能吗? 最佳答案 您无法控制应用在用户设备上的安装,因此无法在安装过程中下载其他数据。 只需在安装后首次启动应
我曾经开发过一款企业版 iOS 产品,我们公司曾将其出售给大型企业,供他们的员工使用。 该应用程序通过 AppStore 提供,企业用户获得了公司特定的配置文件(包含应用程序配置文件)以启用他们有权使
我正在尝试将 Card.io SDK 集成到我的 iOS 应用程序中。我想为 CardIO ui 做一个简单的本地化,如更改取消按钮标题或“在此保留信用卡”提示文本。 我在 github 上找到了这个
我正在使用 CardIOView 和 CardIOViewDelegate 类,没有可以设置为 YES 的 BOOL 来扫描 collectCardholderName。我可以看到它在 CardIOP
我有一个集成了通话工具包的 voip 应用程序。每次我从我的 voip 应用程序调用时,都会在 native 电话应用程序中创建一个新的最近通话记录。我在 voip 应用程序中也有自定义联系人(电话应
iOS 应用程序如何知道应用程序打开时屏幕上是否已经有键盘?应用程序运行后,它可以接收键盘显示/隐藏通知。但是,如果应用程序在分屏模式下作为辅助应用程序打开,而主应用程序已经显示键盘,则辅助应用程序不
我在模拟器中收到以下错误: ImageIO: CGImageReadSessionGetCachedImageBlockData *** CGImageReadSessionGetCachedIm
如 Apple 文档所示,可以通过 EAAccessory Framework 与经过认证的配件(由 Apple 认证)进行通信。但是我有点困惑,因为一些帖子告诉我它也可以通过 CoreBluetoo
尽管现在的调试器已经很不错了,但有时找出应用程序中正在发生的事情的最好方法仍然是古老的 NSLog。当您连接到计算机时,这样做很容易; Xcode 会帮助弹出日志查看器面板,然后就可以了。当您不在办公
在我的 iOS 应用程序中,我定义了一些兴趣点。其中一些有一个 Kontakt.io 信标的名称,它绑定(bind)到一个特定的 PoI(我的意思是通常贴在信标标签上的名称)。现在我想在附近发现信标,
我正在为警报提示创建一个 trigger.io 插件。尝试从警报提示返回数据。这是我的代码: // Prompt + (void)show_prompt:(ForgeTask*)task{
您好,我是 Apple iOS 的新手。我阅读并搜索了很多关于推送通知的文章,但我没有发现任何关于 APNS 从 io4 到 ios 6 的新更新的信息。任何人都可以向我提供 APNS 如何在 ios
UITabBar 的高度似乎在 iOS 7 和 8/9/10/11 之间发生了变化。我发布这个问题是为了让其他人轻松找到答案。 那么:在 iPhone 和 iPad 上的 iOS 8/9/10/11
我想我可以针对不同的 iOS 版本使用不同的 Storyboard。 由于 UI 的差异,我将创建下一个 Storyboard: Main_iPhone.storyboard Main_iPad.st
我正在写一些东西,我将使用设备的 iTunes 库中的一部分音轨来覆盖 2 个视频的组合,例如: AVMutableComposition* mixComposition = [[AVMutableC
我创建了一个简单的 iOS 程序,可以顺利编译并在 iPad 模拟器上运行良好。当我告诉 XCode 4 使用我连接的 iPad 设备时,无法编译相同的程序。问题似乎是当我尝试使用附加的 iPad 时
我是一名优秀的程序员,十分优秀!