cocoa-touch

How to differentiate between annotation pins?

I have three pins on a mapview. I'd like to give each one a different color. In the delegate method viewForAnnotation, I'm doing this: - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{ MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdenti...

Labels aligning in UITableViewCell

I use UITableView with cells created using UITableViewCellStyleSubtitle. Every cell's height is dynamically adjusted using the - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath delegate method. The problem you can see on the picture (note: image updated) How to set up align of textLab...

When my colleague changes code and commits it to the repository I can see the code, but xCode compiles as if his contributions weren't there

Have any other iPhone developers experienced this phenomenon? I can see his contributions in xCode - I see for example my colleague has wrapped a navigation controller around one of my view controllers and added it to my tab bar. Great! That view really did call for a navigation controller and this is a welcome addition to the project...

Any idea why this image masking code does not work?

I have this code to mask an image. Basically, I only work with PNG images. So I have a 300x400 PNG image with 24bits of color (PNG-24). I am not sure if it also has an alpha channel. But there's no transparency in it. Then, there is the image mask which is PNG-8bit without alpha channel. It is just black, grayscale and white. I create...

Preload/predisplay tiles in a CATiledLayer?

On the iPhone (though I imagine it's an equally valid question in Cocoa) I have a UIScrollView around a UIView backed by a CATiledLayer. The way it works by default is to load any uncached/unfetched tiles when my viewport scrolls over a blank section of the CATiledLayer. What I would like to know is if there's a way to trigger CATiledLa...

Any way to install a bookmarlet in Mobile Safari from a native app?

Any way to install a bookmarlet in Mobile Safari from a native app? Has anyone been able to successfully do this? ...

Custom TableViewCell with TextField and first responder

I have a custom TableView cell that contains a TextField and I want it to become the first responder as soon as the view is shown but [textcell.textfield becomeFirstResponder] does not work. I know it's because it's a custom cell in another class and I even tried it there and it didn't work. Anyone know how to pull this off? Thanks... ...

Class method equivalent of -respondsToSelector:

Is there a class method equivalent to -respondsToSelector:? Something like +respondsToSelector:? The reason I am asking is because by implementing -respondsToSelector: on a class level, I get a compiler warning: "found '-respondsToSelector:' instead of '+respondsToSelector:' in protocol(s)". The code looks like this: Class <SomeProto...

Limiting pasted string length in UITextView or UITextField

The problem of limiting strings that are directly entered into a UITextView or UITextField has been addressed on SO before: iPhone SDK: Set Max Character length TextField iPhone sdk 3.0 issue However now with OS 3.0 copy-and-paste becomes an issue, as the solutions in the above SO questions don’t prevent pasting additional characters...

Any quick and dirty anti-aliasing techniques for a rotated UIImageView?

I've got a UIImageView (full frame and rectangular) that i'm rotating with a CGAffineTransform. The UIImage of the UIImageView fills the entire frame. When the image is rotated and drawn the edges appear noticeably jagged. Is there anything I can do to make it look better? It's clearly not being anti-aliased with the background. ...

custom UITableViewCell item problems

Hi, I am a newbie. I have a custom UITableViewCell with 3 items: a UILabel a UITextField and a UIButton My question is, how do I know from which cell the button was clicked or textField was edited ? Is there a way to track them? Thanks for any replies. ...

Does openGL ES have a better performance than Core Animation and UIKit when it comes to highly animated user interfaces?

Currently I have an user interface that makes incredible heavy use of core animation. I wonder if it is worth to spent another 2 months for learning openGL ES? Does that really improve drawing performance for 2D surfaces? I have no 3D objects, but highly animated 2D stuff. Sometimes with 3D distortions, a lot of rotations and scaling. I...

How can I move around and slide away a UIView with touches and swipes?

Hello, I´m trying to animate a sort of draggable UIView where the behaviour should be something like this: Drag along the screen following the touch of the user. Detect a swipe touch and drag automatically with an initial speed and a negative acceleration that makes is stop after some time. Something like moving around a photo and th...

Convert first number in an NSString into an Integer?

I have an NSString like so: @"200hello" or @"0 something" What I would like to be able to do is take the first occuring number in the NSString and convert it into an int. So that @"200hello" would become int = 200. and @"0 something" would become int = 0. ...

UIView animation vs CALayers on iPhone

I'm struggling with conceptualizing animations with a CALayer as opposed to UIView's own animation methods. Throw "Core Animation" into this and, well, maybe someone can articulate these concepts from a high level so I can better visualize what's happening and why I'd want to migrate UIView animations (which I'm quite familiar with now) ...

Refresh a View Controller

In my app delegate, I have this method that gets stubbed out automatically, to do something when a view controller gets selected. If the type of the viewController is SavedViewController, then it's a UITableView subclass, and I would like to refresh the table. However, this code doesn't work: - (void)tabBarController:(UITabBarControlle...

Is there a better way to write this working, but extremely ugly, code?

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { NSLog(@"switching views"); if([viewController isKindOfClass: [UINavigationController class]] && [[[viewController viewControllers] objectAtIndex: 0] isKindOfClass: [SavedViewController class]]) { N...

What's the easiest way to determine inside a method if it has been called the first time since app start?

I have a method where I do some startup animations. The method gets called many times during usage of the app, but on it's first call it needs to do some special things in addition. Are Singletons the way to go? Maybe there is also an better way, instead of measuring how many times this method was called, and storing that in an ivar. ...

How can I count how many times an view has been loaded since application start?

Some methods of my class need to know how many times the class has been loaded. Do I need a Singleton for this, or are there other ways to do this? Are there static variables that I can attach to the class and then just increment them every time a viewDidLoad? When the application starts, that value is resetted (=0). I'm not such a big ...

Can't get FileCreationDate?

In my app, I create a directory, and then the following code works: NSDictionary *fileAttributes = [fileManager fileAttributesAtPath:trackDirectory traverseLink:YES]; NSDate *fileDate = [fileAttributes objectForKey:NSFileModificationDate]; However, when I try and get the NSFileCreationDate instead, it doesn't work. What am I doing w...