cocoa-touch

Resizing UILabel to fit with Word Wrap

This is part of an iPhone application but should apply to Cocoa written in objC in general. I have a UILabel holding various amounts of text (from single characters to several sentences). The text should always be displayed in the largest possible font that fits all the text within the UILabel. The maximum number of lines is set to 4 an...

Cocoa Touch: How to detect a missing file on the download server

My iOS app downloads document files from a server using the NSURLConnection class. I use it asynchronously. It can happen that a document is missing from the server (configuration error). I expected NSURLConnection to call my delegate error method: - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error But...

UITextView Custom Auto-completion.

Is there a way to implement custom Auto-completion for a UITextView, say by giving it a NSDictionary or NSArray of Strings to watch out for? ...

Touch debouncing on iPod/iPad

Is it common practice to do some kind of debouncing / refractory period for handling user touches? I have a view based app with quite a few UI objects that are currently using touchUpInside to flip states. I notice that its almost easy to double touch or cycle the state more than once. Since the gameplay is relatively fast it doesn't ...

Cocoa Touch - AVAudioPlayer

I put my avfoundation into frameworks by adding existing frameworks and importing it into my viewcontroller like this #import <AVFoundation/AVAudioPlayer.h> I then called it in my IBAction so when a button pressed it, it plays like so. -(IBAction)playSound{ //play the cricket noise NSString *path = [[NSBundle mainBundle] pathForResour...

How can I use a single UIToolbar with multiple different UIViewControllers?

I have a simple app with two basic screens, a UIMapView and a UITableView. I'd like to have a toolbar at the bottom with a couple of buttons and a UISegmentedControl with two segments: "Map" and "Table". (The layout is similar to the Google Maps app that ships with the iPhone.) How can I keep the same toolbar while presenting either the ...

Does it matter when super is called in dealloc?

- (void)dealloc { [super dealloc]; [receivedData release]; receivedData = nil; } or - (void)dealloc { [receivedData release]; receivedData = nil; [super dealloc]; } ...

Cocoa Touch - Loading AVAudioPlayer

I have this code to play a sound but the first time you play it it takes a good 5 seconds to load... How can I speed this up? -(IBAction)playSound{ //play the cricket noise NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"Cricket_Sound" ofType:@"mp3"]; audioPlayer =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fil...

iPhone - A text in a text

Hi everyone, I would like to have a text in a text... I mean like in the newspaper: when there is a picture, the text fits and follow the border of the picture. For example: http://en.wikipedia.org/wiki/Iphone look at the pictures... the text follows them! Is it possible to do that on the iPhone? Thanks in advance ...

Monitor iphone application api calls

I was wondering if there is any way to monitor 3rd party iphone applications' api calls? For instance if application access address book is there a way to monitor that or intercept call? I understand it may not be possible to do so without jail-breaking, but is even possibility after having jail broken the phone? Thanks! ...

iOS 4 Application Termination and Undo

What is a good way to handle iOS 4 app termination when using an NSUndoManager? I have an iPhone (iOS 4) application that uses Core Data. The app allows the user to edit managed objects, and I implement undo using NSUndoManager in a straightforward manner: Before displaying an editor view modally, I create a new NSUndoManager for the ma...

Is it ok to autorelease UIViewControllers?

I have some view controllers: StockTwitsTVViewController* stvViewController = [[[StockTwitsTVViewController alloc] initWithNibName:@"StockTwitsTVViewController" bundle:nil]autorelease]; UINavigationController *stvNavController = [[UINavigationController alloc] initWithRootViewController:stvViewController]; stvNavController.tabBa...

How to calculate UILabel width based on text length?

I want to display an image next to a UILabel, however UILabel has variable text length, so I don't know where to place the image. How can I accomplish this? ...

sizeWithFont in MultiThread Crash!

sizeWithFont crashed in multithread,this is the debug info: 1 0x00a0df8e in icu::RuleBasedBreakIterator::handleNext 2 0x00a0daff in icu::RuleBasedBreakIterator::next 3 0x00a0d174 in icu::RuleBasedBreakIterator::following 4 0x35879719 in WebCore::nextBreakablePosition 5 0x3587842a in -[NSString(WebStringDrawing) _web_drawInRect:withFont:...

Resize image in UITableViewCell to not be total height

Current I am trying to show a simple table in my iPhone application where I use UITableViewCell's with the style UITableViewCellStyleValue1 (image to the left, detail-label right-alligned). The cells all have the default height (50.0f). Before I add an image to the cell, I resize the image to be 40x40, so that it is not the total height ...

Resizing layers and its sublayers - CoreAnimation

Hi, I have a CALayer A with one sublayer B I want A to be resized (to be shrank) so I add the animations to my layer A but when I commit the animation sublayer B is not shrank. Its size remains(but its position changes as its superlayer bounds changes) How can I make my B layer to be resized along with A animation? This is what I wrote...

Return 1st from 1, 2nd from 2, ..., 11th from 11, ...

Is there a Objective-c function to return a NSString * from a NSUInteger, i.e.: 1 -> 1st 2 -> 2nd ... 10 -> 10th 21 -> 21st ... 31 -> 31st for the range from 1 to 31. Thanks! ...

When should I use Class Method instead of an init Instance Method?

This is an example straight from Apple's documentation - @implementation MyClass - (id)initWithString:(NSString *)aName { self = [super init]; if (self) { name = [aName copy]; } return self; } + (MyClass *)createMyClassWithString: (NSString *)aName { return [[[self alloc] initWithString:aName] autorelease];...

Accordion Menu in XCODE

hey, I'm trying to make a accordion menu in Objective-C for a iPad app. The only thing I know is that I should look over core animation. Couldn't find anything helpfull. Can anyone help me ? at least give me a few pointers. ...

static UIAlertView not called willPresentAlertView

In the below code not invoked the willPresentAlertView method. Why? The method is static? or The Alert value is static? @interface ShowAlert : NSObject <UIAlertViewDelegate> static UIAlertView* alert; +(void) showAlert:(NSString*) msg{ alert = [[UIAlertView alloc] initWithTitle:nil message:[NSString stringWithFormat:...