How to display 2 lines of text for subtitle of MKAnnotation and change the image for the button on the right?

plz use this – (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { if ([annotation isKindOfClass:[MKUserLocation class]]) return nil; if ([annotation isKindOfClass:[CustomAnnotation class]]) { CustomAnnotation *customAnnotation = (CustomAnnotation *) annotation; MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:@”CustomAnnotation”]; if (annotationView == nil) annotationView = customAnnotation.annotationView; else annotationView.annotation = annotation; //Adding multiline subtitle code UILabel *subTitlelbl = [[UILabel alloc]init]; subTitlelbl.text = @”sri … Read more

How to use Shake API in iPhone SDK 3.0?

The APIs you are looking for are in UIResponder: – (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event; – (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event; – (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event; Generally you just implement this: – (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (event.type == UIEventSubtypeMotionShake) { //Your code here } } in your UIViewController subclass (UIViewController is a subclass of UIResponder). Also, you want to … Read more

How to subclass UIApplication?

Did you pass the name of your subclass to UIApplicationMain? Let’s assume you have @interface MyUIApp : UIApplication … then in main() you should do: NSString* appClass = @”MyUIApp”; NSString* delegateClass = nil; int retVal = UIApplicationMain(argc, argv, appClass, delegateClass);

Custom MKPinAnnotation callout bubble similar to default callout bubble

I have developed a custom callout bubble that is nearly identical to the system callout bubble, but gives more flexibility over the height and content. It should be fairly trivial to adjust the appearance to suit your needs. See my post on the Asynchrony Solutions blog for example code and the steps required to implement … Read more

Localize Currency for iPhone

NSNumberFormatter is definitely the way to go! You can set a NSLocale on the NSNumberFormatter, the formatter will automatically behave according to that locale. The default locale for a number formatter is always the currency for the users selected region format. NSDecimalNumber *someAmount = [NSDecimalNumber decimalNumberWithString:@”5.00″]; NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init]; [currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; NSLog(@”%@”, … Read more

iOS – How to limit the MapView to a specific region?

After trying different ways of limited MKMapView I’ve concluded that using mapDidChange, and resetting if you’re center point goes outside of the boundaries works best, with animated: YES Here’s how I do it (Using the New Zealand lat/Long span/center). – (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{ if ((mapView.region.span.latitudeDelta > 15.589921 ) || (mapView.region.span.longitudeDelta > 175.836914) ) { CLLocationCoordinate2D … Read more

MPMediaItems raw song data

you can obtain the media item’s data in such way: -(void)mediaItemToData { // Implement in your project the media item picker MPMediaItem *curItem = musicPlayer.nowPlayingItem; NSURL *url = [curItem valueForProperty: MPMediaItemPropertyAssetURL]; AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL: url options:nil]; AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset: songAsset presetName: AVAssetExportPresetPassthrough]; exporter.outputFileType = @”public.mpeg-4″; NSString *exportFile = [[self myDocumentsDirectory] … Read more

Is it possible to hide the tabbar when a button is pressed to allow a full screen view of the content?

There’s a built-in way to do this: self.hidesBottomBarWhenPushed = YES; But you have to do this BEFORE the view is pushed. This is how you might want to use that: ChildViewController* childVC = [[ChildViewController alloc] init]; childVC.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:childVC animated:YES]; [childVC release];