cocoa-touch

UITextView textView:shouldChangeTextInRange:replacementText: doesn't fire when deleting large portions of text?

I am trying to implement a character counter for a UITextView, but have found the counter to be inaccurate in the following situation: Enter a few characters of text, such as "The" Tap return 25 times Hold down the delete button to delete the text (and hold it down until the cursor gets to the top) When the cursor reaches the top (and ...

Rotate MapView using Compass orientation

Is it possible to have an embedded MKMapView rotate to always face the direction the iPhone is facing? Basically I want to mimic the Map app rotation feature on my own app. I see that the iPhone SDK does not expose the functionality. However, I wonder if it would work to rotate the entire view using CGAffineTransformMakeRotate. Would...

Undo Management with Core Data

I'm trying to implement undo support using Core Data on the iPhone and I ran into a few problems. I currently have a couple of managed objects set up but when I make changes to their properties, these changes don't get recorded by the undo manager. From my understanding, Core Data is supposed to have this automatically set up and I shou...

Show iPhone cut copy paste menu on UILabel

Can we enable the cut copy paste menu for a UILabel as it is for a UITextField? If not, and I need to convert my UILabel to UITextField, how can I enable the cut copy paste menu and not allow the content to be modified? ...

Need content in UIWebView to display quickly

Part of my app caches web pages for offline viewing. To do that, I am saving the HTML fetched from a site and rewriting img urls to point to a file on the local store. When I load the html into a UIWebView, it loads the images as expected and everything's fine. I am also caching stylesheets in this fashion. The problem is that when I pu...

UITextField for Phone Number

Hello everyone, I was wondering how I can format the textField that I'm using for a phone number (ie like the "Add New Contact" page on the iPhone. When I enter in a new mobile phone, ex. 1236890987 it formats it as (123) 689-0987.) I already have the keyboard set as the number pad. Thanks! ...

iPhone: get duration of an audio file

Hi, What is the easiest way to get a duration of an audio file? I could create an object of AVAudioPlayer, initialize it with URL and than get the duration, but this way is too long. Is there an easier way? Thanks. ...

Notify changes in property for Core Data?

The user will be able to add or change some value (property in my model with Core Data) in one view, when the user switch to another view, I want to show the newly added/changed value with an animation. Is there a way to get a notification that there has been a change or an update for a property with Core Data? ...

Override UILabel's setText method?

I'd like to override UILabel's setText method but I'm not sure that A) it's possible and B) if maybe there's a better way to achieve what I'm trying to accomplish. I have a subclass of UIView that has a UILabel property as one of its subviews. I'd like to know when the UILabel's "text" property changes so I can adjust the size of the r...

iPhone: Increase volume

Hi, I have got an audio file which is quite quiet. I'd am playing it using AVAudioPlayer, but I can barely hear anything, especially without headphones. Is there a way to increase the volume of an audio record? Thanks. ...

Security implications of storing a password in Settings.bundle and getting with CFPreferencesCopyAppValue

Hello, Apologies for the seeming obviousness of this question, but for whatever reason I haven't been able to find a definitive answer in the Apple documentation about where and how Settings.bundle password info is stored. My question: if I need to store some credentials for an app, and I use a Settings.bundle so that the password is en...

iPhone: available disk space

Hi, I am creating an audio-recording application and I need to know how much disk space is available (not ram). How can I retrieve it? Thanks. ...

Cocoa Touch - UITableView within a View

Greetings, Problem: I have a main view, that already is associated with a xib file, an appdelegate class, and a controller class. Now, opening its xib file in interface builder, I add a UITableView. Then, in its controller class, I create the IBoutlet code to use it, let's say: tableView. Questions: 1) Where do I go from here in...

Would you ever use this, or have you ever thought about something like it? (custom Nav Controller for iPhone)

Here's a little blogpost on the library: http://www.andrewljohnson.com/article/Customizing%20UINavigationControlBar%20-%20Controls%20and%20Images And here's a link directly to the GitHub repository: http://github.com/andrewljohnson/NavControlBar/tree/master I searched SO and the rest of the internets for how best to do this recently, a...

UITabBarController UINavigationController Design Advice

This is more of a philosophical question than anything, so give me your thoughts. The iPhone SDK documentation specifies that you may have a tab bar controller contain a navigation controller, but you can't have a navigation controller contain a tab bar controller. It seems that there are times when you might want to organize views with...

How to end an animation early in Cocoa Touch?

I have a UINavigationController onto which I push a 'loading screen' UIViewController whilst I asynchronously connect to a server. The push is implicitly animated with that sliding effect. If an error occurs whilst connecting, I pop the loading screen controller (again animated) and display an alert to the user. All is good if I pop ...

Draggable cards (touch enumeration) issue

I'm trying to let a player tap, drag and release a card from a fanned stack on the screen to a 4x4 field on the board. My cards are instantiated from a custom class that inherits from the UIImageView class. I started with the Touches sample app, and I modified the event handlers for touches to iterate over my player's card hand instead ...

Amount of touches

Hi, I want to get amount of taps anywhere on the screen. Here is my code: -(void) touchesEnded: (NSSet *)touches withEvent: (UIEvent *)event { DebugLog(@"touches: %d", [touches count]); } This method is implemented in an active view controller. But it doesn't detect multiple taps - it reports me them as a single tap. How can I...

memory leak problem using NSData in iPhone

Memory leak problem - NSConcreteData // to set tip - photo in photo frame NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:pathOfThumbNail]]; UIImage *cellThumbImg; if([data length]>0){ cellThumbImg=[UIImage imageWithData:data];} else { cellThumbImg=[UIImage imageNamed:@"130X90.gif"]; } UIImageView *imgView=[[UIImage...

Why does this code from iPhone Developer's Cookbook work?

I've been trying out some of the view code from Erica Sadun's book "The iPhone Developer's Cookbook" and found some code I don't understand. Here's the code for a loadView method: - (void)loadView { // Create the main view UIView *contentView = [[UIView alloc] initWithFrame: [[UIScreen mainScreen] applicationFrame]]; contentView.b...