Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-08-2010, 10:21 AM   #1 (permalink)
Registered Member
 
Join Date: Dec 2009
Location: florida
Posts: 3
designomatt is on a distinguished road
Default calloutAccessoryControlTapped use

I am working in MapKit and trying to build out detail views of annotations through the "calloutAccessoryControlTapped" control. I want to pull a local HTML file detailing the points on the map into an existing UIWebView that I use in another portion of the app from the plist that stores all of the annotation data.

I am able to create the annotations, add unique icons for the annotations and push a the UIWebView, but I cannot for the life of me figure out how to load these local detail webpages into the view.

Has anyone faced this and come up with a viable solution?

plist item (truncated for this post - but they repeat for all points on the map)

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd>">
<plist version="1.0">
<array>
     <dict>
          <key>name</key>
          <string>Title</string>
          <key>address</key>
          <string>Subtitle</string>
          <key>latitude</key>
          <real>28.538335</real>
          <key>longitude</key>
          <real>-81.379236</real>
          <key>imageName</key>
          <string>pin_001.png</string>
          <key>bulletName</key>
          <string>pin_001a.png</string>
          <key>detailURL</key>
          <string>test.html</string>
     </dict>
</array>
</plist>
MyAnnotation.h

Code:
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>

@interface MyAnnotation : NSObject <MKAnnotation> {

     CLLocationCoordinate2D coordinate;
     NSString *title;
     NSString *subtitle;
     NSString *imageName;
     NSString *bulletName;
     NSString *detailURL;
}

@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle;
@property (nonatomic, retain) NSString *imageName;
@property (nonatomic, retain) NSString *bulletName;
@property (nonatomic, retain) NSString *detailURL;

@end
MyAnnotation.m

Code:
#import "MyAnnotation.h"

@implementation MyAnnotation
@synthesize coordinate, title, subtitle, imageName, bulletName, detailURL;

- (id) initWithDictionary:(NSDictionary *) dict
{
     self = [super init];
     if (self != nil) {
          coordinate.latitude = [[dict objectForKey:@"latitude"] doubleValue];
          coordinate.longitude = [[dict objectForKey:@"longitude"] doubleValue];
          self.title = [dict objectForKey:@"name"];
          self.subtitle = [dict objectForKey:@"address"];
          self.imageName = [dict objectForKey:@"imageName"];
          self.bulletName = [dict objectForKey:@"bulletName"];
          self.detailURL = [dict objectForKey:@"detailURL"];
     }
     return self;
}

@end
calloutAccessoryControlTapped

Code:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {

     //this determines what kind of item was selected
     if ([control isKindOfClass:[UIButton class]]) {

          //pushes the blank WebVC controller for all annotations
          WebVC *webVC = [[WebVC alloc] initWithNibName:@"WebVC" bundle:nil];
          [self.navigationController pushViewController:webVC animated:YES];

                //titles the new view
          webVC.title = @"Detail View";
                //releases the view
          [webVC release];
     }
}
The above works as you load a map, select an annotation and click:
Code:
 annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
The "Detail View" pushes in and loads a blank UIWebView. It is loading those unique local HTML files to showcase detailed descriptions I cannot figure out.

I would be grateful if anyone could help with some direction for solving this conundrum, or if you have worked through this how you successfully managed this process. TIA
designomatt is offline   Reply With Quote
Old 02-18-2010, 02:49 PM   #2 (permalink)
Registered Member
 
Join Date: Dec 2009
Location: florida
Posts: 3
designomatt is on a distinguished road
Default

Here is one of the things I had been searching for in order to "know" which annotation was selected.

Code:
 if([view.annotation.title isEqualToString:@"Annotation Title Here"])
Knowing that you can then push another view controller or, in this case below, call up an alert view:

Code:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control{
     
     if([view.annotation.title isEqualToString:@"Annotation Title Here"]){ [[[[UIAlertView alloc] initWithTitle:view.annotation.title
     message:@"Enter message here" 
     delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease] show];

}
This is exactly what I was looking for in trying to leverage the calloutAccessoryControlTapped. Perhaps this will help someone else.
designomatt is offline   Reply With Quote
Old 02-28-2010, 06:46 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 8
upperhouse is on a distinguished road
Default

Quote:
Originally Posted by designomatt View Post
This is exactly what I was looking for in trying to leverage the calloutAccessoryControlTapped. Perhaps this will help someone else.
Sure did.
Thanks for posting this!
upperhouse is offline   Reply With Quote
Old 06-06-2010, 02:53 AM   #4 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 51
damniatx is on a distinguished road
Default

Thanks for solution.
works great.
damniatx is offline   Reply With Quote
Old 07-28-2010, 08:44 PM   #5 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 6
smaramba is on a distinguished road
Default

Quote:
Originally Posted by designomatt View Post
Here is one of the things I had been searching for in order to "know" which annotation was selected.

Code:
 if([view.annotation.title isEqualToString:@"Annotation Title Here"])
.
Hi,
im' sorry, i had try this but for me don't work it.
I had change

Code:
 if([view.annotation.title isEqualToString:@"Annotation Title Here"])
.[/quote]

to
Code:
if ([view.annotation isEqual:[PV4007 class]]) {
		CalloutViewController *detPV = [[CalloutViewController alloc] initWithNibName:@"Callout" bundle:nil];
		[self.navigationController pushViewController:detPV animated:YES];
		
	}
}
because i have the annotations in more class.. and i need to associate 1 kind of nib and class for 1 kind of annotation.
i had add annotation in view did load like this.

Code:
- (void)viewDidLoad {

	[mappa addAnnotation:[[PV4007 alloc] init]];
	mappa.delegate = self;
}
Where i'm wrong??tnx
smaramba is offline   Reply With Quote
Reply

Bookmarks

Tags
map, mapkit, mkmapkit

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 321
6 members and 315 guests
2Apps1Day, akacaj, SLIC, soohyun, Techgirl-52, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,650
Threads: 94,115
Posts: 402,887
Top Poster: BrianSlick (7,990)
Welcome to our newest member, soohyun
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:06 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0