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
231
votes
10 answers

Can I force a UITableView to hide the separator between empty cells?

When using a plain-style UITableView with a large enough number of cells that the UITableView cannot display them all without scrolling, no separators appear in the empty space below the cells. If I have only a few cells the empty space below them…
jessecurry
  • 22,068
  • 8
  • 52
  • 44
228
votes
11 answers

Autolayout - intrinsic size of UIButton does not include title insets

If I have a UIButton arranged using autolayout, its size adjusts nicely to fit its content. If I set an image as button.image, the instrinsic size again seems to account for this. However, if I tweak the titleEdgeInsets of the button, the layout…
Ben Packard
  • 26,102
  • 25
  • 102
  • 183
227
votes
9 answers

Is there a way to remove the separator line from a UITableView?

I'm looking for a way to completely remove the separator line in a UITableView when in the plain mode. This is done automatically in grouped, but this also changes the dimensions of the table in a way that is hard to measure. I have set the…
Tricky
  • 7,025
  • 5
  • 33
  • 43
227
votes
37 answers

How do I change the title of the "back" button on a Navigation Bar

Currently the left bar button default value is the title of the view that loaded the current one, in other words the view to be shown when the button is pressed (back button). I want to change the text shown on the button to something else. I tried…
Dale
  • 3,527
  • 6
  • 24
  • 22
221
votes
7 answers

Gradients on UIView and UILabels On iPhone

Possible Duplicate: Manually drawing a gradient in iPhone apps? My application needs to display text in either a UIView or UILabel but the back ground must be a gradient as opposed to a true UIColor. Using a graphics program to create desired…
TonyNeallon
  • 6,607
  • 12
  • 42
  • 49
221
votes
7 answers

capturing self strongly in this block is likely to lead to a retain cycle

How can I avoid this warning in xcode. Here is the code snippet: [player(AVPlayer object) addPeriodicTimeObserverForInterval:CMTimeMakeWithSeconds(0.1, 100) queue:nil usingBlock:^(CMTime time) { current+=1; if(current==60) { …
220
votes
26 answers

Cropping an UIImage

I've got some code that resizes an image so I can get a scaled chunk of the center of the image - I use this to take a UIImage and return a small, square representation of an image, similar to what's seen in the album view of the Photos app. (I know…
218
votes
5 answers

How do I enter RGB values into Interface Builder?

How can I enter RGB or Hex color values for backgrounds in Interface Builder? I can select predefined colors but I would like to manually enter in RGB values. Where can I do this?
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556
217
votes
4 answers

Autoresizing masks programmatically vs Interface Builder / xib / nib

I was in an (probably false) assumption that enabling the right margin indicator in xib is equivalent to using UIViewAutoresizingFlexibleLeftMargin inside code and so on. So, I used to think according to this snapshot: Later today I had to cross…
Raj Pawan Gumdal
  • 7,390
  • 10
  • 60
  • 92
214
votes
31 answers

Is it possible to disable floating headers in UITableView with UITableViewStylePlain?

I'm using a UITableView to layout content 'pages'. I'm using the headers of the table view to layout certain images etc. and I'd prefer it if they didn't float but stayed static as they do when the style is set to UITableViewStyleGrouped. Other then…
Tricky
  • 7,025
  • 5
  • 33
  • 43
212
votes
11 answers

In Swift how to call method with parameters on GCD main thread?

In my app I have a function that makes an NSRURLSession and sends out an NSURLRequest using sesh.dataTaskWithRequest(req, completionHandler: {(data, response, error) In the completion block for this task, I need to do some computation that adds a…
almel
  • 7,178
  • 13
  • 45
  • 58
211
votes
6 answers

How does the new automatic reference counting mechanism work?

Can someone briefly explain to me how ARC works? I know it's different from Garbage Collection, but I was just wondering exactly how it worked. Also, if ARC does what GC does without hindering performance, then why does Java use GC? Why doesn't it…
205
votes
11 answers

How to get pixel data from a UIImage (Cocoa Touch) or CGImage (Core Graphics)?

I have a UIImage (Cocoa Touch). From that, I'm happy to get a CGImage or anything else you'd like that's available. I'd like to write this function: - (int)getRGBAFromImage:(UIImage *)image atX:(int)xx andY:(int)yy { // [...] // What do I want…
Olie
  • 24,597
  • 18
  • 99
  • 131
203
votes
17 answers

Have a reloadData for a UITableView animate when changing

I have a UITableView that has two modes. When we switch between the modes I have a different number of sections and cells per section. Ideally, it would do some cool animation when the table grows or shrinks. Here is the code I tried, but it…
Chris Butler
201
votes
26 answers

Zooming MKMapView to fit annotation pins?

I am using MKMapView and have added a number of annotation pins to the map about a 5-10 kilometre area. When I run the application my map starts zoomed out to show the whole world, what is the best way to zoom the map so the pins fit the…
fuzzygoat
  • 26,573
  • 48
  • 165
  • 294