Tag: cocoa touch

How to use edge insets in iOS?

How would I use edge insets to make an image fit inside a button? I’m not sure what values to use for the arguments in UIEdgeInsetsMake(). Could I somehow use the button’s width and height to set them? I want the button to just be an image when not selected. I understand how to do […]

How To Save Data For Bookmarks?

I’m creating a very simple bookmarks menu for my app. I just need to save 3 strings for each object. I was thinking of using core data but I don’t want this to be connected with my core database for various reasons. Therefore what other easy options do I have? NSUserDefaults or .plist? I just […]

Strange behavior of MKMapView visibleMapRect property

I tried to set visibleMapRect property of MKMapView object but result map rect is not the exact what I expected. This is my code: NSLog(@”current size %f %f”, mapView.visibleMapRect.size.width, mapView.visibleMapRect.size.height); NSLog(@”target size %f %f”, newBounds.size.width, newBounds.size.height); mapView.visibleMapRect = newBounds; NSLog(@”new size %f %f”, mapView.visibleMapRect.size.width, mapView.visibleMapRect.size.height); And this is the result: 2013-01-15 19:21:25.440 MyApp[4216:14c03] current size […]

AVAudioRecorder and AirPlay Mirrioring

When I have an AVAudioRecorder Session active – (when I’m recording audio) I can’t activate AirPlay mirroring on the device. Airplay mirroring just deactivates while the app is running and switches it back on when the app exits. This post seems to suggest there is no way around this. My thoughts are to try: using […]

How To Create A Custom Center Tab Button?

I’m trying to follow this tutorial here to recreate a custom center tab button, but I already have my tabbarcontroller setup in IB. Can anyone help me do this? The tutorial does it all through code so its difficult to follow. http://idevrecipes.com/2010/12/16/raised-center-tab-bar-button/

NSNumberFormatter numberFromString decimal number

I’m trying to parse a NSString with a NSNumberFormatter like following. NSNumberFormatter *myFormatter = [[[NSNumberFormatter alloc] init]; NSNumber *myNumber = [myFormatter numberFromString:@”42.00000″]; numberFromString returns a NSNumber object in the simulator but not on a device. The decimals (.00000) are causing the return value to be nil on a device because parsing 42 (without the decimals) […]

NSMutableArray becoming nil after reloadData

In an iPhone app I’m developing, I grab a set of data from a web service, store it in a mutable array for showing in a table, and also store it in core data as backup when there is no network. My array is initialized in application:didFinishLaunchingWithOptions: as follows tableArray = [[NSMutableArray alloc] initWithCapacity:100]; the […]

Creating a file name by adding two NSStrings

I am trying to load a file. The file name depends on a string stored in an array. In the following example, I would like to load tabRed.png. @”Red” is stored in an array. This is what I tried: UIImage *tabImage = [UIImage imageNamed:(@”tab%@.png”, [self.currentNoteBook.tabColours objectAtIndex:0])]; But I only got “Red” as an output and […]

Unable to add the file iOS application bundle

I have added an empty file with extension .js in resource path but that is not added to application’s bundle. I am sure that I have added to application target, but sometimes it includes in bundle and sometimes it doesn’t include in bundle. I am fetching the file’s content by following code: NSString *filePath = […]

How can I programmatically launch Contacts.app on the iPhone

I would like to launch the Contacts.app when the user needs to add a contact. My app already reads from the contact API. I would rather not re-implement functionality if I can avoid it. I am targeting iOS 4.0 and above.