Questions tagged [cocoa-touch]

The Cocoa Touch Frameworks that drive iOS apps share many proven patterns found on the Mac, but were built with a special focus on touch-based interfaces and optimization.

Cocoa Touch is Apple's application-development framework for , consisting of Foundation, UIKit (), and Core Data ().

The Cocoa Touch frameworks that drive apps share many proven patterns found on the , but were built with a special focus on touch-based interfaces and optimization.

For development, see .

For Cocoapods, see .

Many Cocoa Touch questions deal with , , , or .

Debugging techniques

Cocoa programs can be debugged with many techniques and tools, both general and specific to , , , and .

Apple's Technical Note about debugging iOS applications

34585 questions
365
votes
28 answers

Get the current first responder without using a private API

I submitted my app a little over a week ago and got the dreaded rejection email today. It tells me that my app cannot be accepted because I'm using a non-public API; specifically, it says, The non-public API that is included in your application is…
Justin Kredible
  • 8,354
  • 15
  • 65
  • 91
365
votes
24 answers

How to use Auto Layout to move other views when a view is hidden?

I have designed my custom Cell in IB, subclassed it and connected my outlets to my custom class. I have three subviews in cell content which are: UIView (cdView) and two labels (titleLabel and emailLabel). Depending on data available for each row,…
Guferos
  • 4,337
  • 5
  • 18
  • 25
358
votes
16 answers

How do I draw a shadow under a UIView?

I'm trying to draw a shadow under the bottom edge of a UIView in Cocoa Touch. I understand that I should use CGContextSetShadow() to draw the shadow, but the Quartz 2D programming guide is a little vague: Save the graphics state. Call the function…
Fraser Speirs
  • 4,642
  • 3
  • 21
  • 15
357
votes
16 answers

UITableView didSelectRowAtIndexPath: not being called on first tap

I'm having an issue with UITableView's didSelectRowAtIndexPath. My table is setup so that when I select row it initializes a new view controller and pushes it. The first time I tap any row in the table, the method does not get called. Once I select…
Mark Adams
  • 30,776
  • 11
  • 77
  • 77
351
votes
34 answers

UITableView - change section header color

How can I change color of a section header in UITableView? EDIT: The answer provided by DJ-S should be considered for iOS 6 and above. The accepted answer is out of date.
Ilya Suzdalnitski
  • 52,598
  • 51
  • 134
  • 168
348
votes
20 answers

iOS UIImagePickerController result image orientation after upload

I am testing my iPhone application on an iOS 3.1.3 iPhone. I am selecting/capturing an image using a UIImagePickerController: UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; [imagePicker…
james
  • 26,141
  • 19
  • 95
  • 113
348
votes
17 answers

How to scale a UIImageView proportionally?

I have a UIImageView and the objective is to scale it down proportionally by giving it either a height or width. UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL…
Ronnie Liew
  • 18,220
  • 14
  • 46
  • 50
346
votes
33 answers

What are best practices that you use when writing Objective-C and Cocoa?

I know about the HIG (which is quite handy!), but what programming practices do you use when writing Objective-C, and more specifically when using Cocoa (or CocoaTouch).
pixel
  • 5,298
  • 8
  • 35
  • 32
336
votes
10 answers

NSString property: copy or retain?

Let's say I have a class called SomeClass with a string property name: @interface SomeClass : NSObject { NSString* name; } @property (nonatomic, retain) NSString* name; @end I understand that name may be assigned a NSMutableString in which…
Debajit
  • 46,327
  • 33
  • 91
  • 100
333
votes
38 answers

UILabel text margin

I'm looking to set the left inset/margin of a UILabel and can't find a method to do so. The label has a background set so just changing its origin won't do the trick. It would be ideal to inset the text by 10px or so on the left hand side.
Ljdawson
  • 12,091
  • 11
  • 45
  • 60
331
votes
8 answers

Generate a UUID on iOS from Swift

In my iOS Swift app I want to generate random UUID (GUID) strings for use as a table key, and this snippet appears to work: let uuid = CFUUIDCreateString(nil, CFUUIDCreate(nil)) Is this safe? Or is there perhaps a better (recommended) approach?
zacjordaan
  • 3,731
  • 2
  • 18
  • 16
330
votes
5 answers

How do I associate file types with an iPhone application?

On the subject of associating your iPhone app with file types. In this informative question I learned that apps could be associated with custom URL protocols. That was almost one year ago and since then Apple introduced 'Document Support' which…
Mihai Damian
  • 11,193
  • 11
  • 59
  • 81
328
votes
12 answers

How to print Boolean flag in NSLog?

Is there a way to print value of Boolean flag in NSLog?
Devang
  • 11,258
  • 13
  • 62
  • 100
327
votes
34 answers

Adjust UILabel height depending on the text

Consider I have the following text in a UILabel (a long line of dynamic text): Since the alien army vastly outnumbers the team, players must use the post-apocalyptic world to their advantage, such as seeking cover behind dumpsters, pillars, cars,…
Mustafa
  • 20,504
  • 42
  • 146
  • 209
307
votes
60 answers

-didSelectRowAtIndexPath: not being called

I'm writing an iOS app with a table view inside a tab view. In my UITableViewController, I implemented -tableView:didSelectRowAtIndexPath:, but when I select a row at runtime, the method isn't being called. The table view is being populated though,…
Matt Pfefferle
  • 209
  • 2
  • 6
  • 14