Questions tagged [uikit]

UIKit (not to be confused with the front-end framework GetUIKit) is the object-oriented framework that is responsible for most of the iOS user interface.

UIKit (not to be confused with the front-end framework ) is the object-oriented framework that is responsible for most of the user interface. UIKit is part of the umbrella framework, and it is to Cocoa Touch as AppKit is to the Cocoa framework on macOS. The classes in UIKit determine the basic structure of most iOS applications as well as the majority of distinctive user interface elements that make iOS apps easily recognizable and instantly familiar.

UIKit provides the classes and protocols that lie at the foundation of any iOS application, including:

  • UIApplication
  • UIResponder
  • UIView
  • UIWindow
  • UIControl
  • UIEvent
  • UIViewController
  • UINavigationController
  • UITabBarController
  • UISplitViewController

It also provides the user interface elements with which all iOS users are familiar:

  • UIButton
  • UITextField
  • UITextView
  • UINavigationBar
  • UIToolbar
  • UITabBar
  • UISwitch
  • UILabel
  • UIScrollView
  • UITableView
  • UITableViewCell
  • UIPickerView

These lists are not exhaustive, but only meant to give a sense of the scope of the UIKit framework. A more complete list is found in the UIKit Framework Reference.

11807 questions
2333
votes
51 answers

Vertically align text to top within a UILabel

I have a UILabel with space for two lines of text. Sometimes, when the text is too short, this text is displayed in the vertical center of the label. How do I vertically align the text to always be at the top of the UILabel?
Stefan
  • 28,843
  • 15
  • 64
  • 76
581
votes
19 answers

UITableViewCell, show delete button on swipe

How do I get the delete button to show when swiping on a UITableViewCell? The event is never raised and the delete button never appears.
TheLearner
  • 19,387
  • 35
  • 95
  • 163
563
votes
24 answers

How to lose margin/padding in UITextView

I have a UITextView in my iOS application, which displays a large amount of text. I am then paging this text by using the offset margin parameter of the UITextView. My problem is that the padding of the UITextView is confusing my calculations as it…
sniurkst
  • 7,212
  • 5
  • 30
  • 30
561
votes
41 answers

How do I size a UITextView to its content?

Is there a good way to adjust the size of a UITextView to conform to its content? Say for instance I have a UITextView that contains one line of text: "Hello world" I then add another line of text: "Goodbye world" Is there a good way in Cocoa…
drewh
  • 10,077
  • 7
  • 34
  • 43
545
votes
18 answers

How to get the screen width and height in iOS?

How can one get the dimensions of the screen in iOS? Currently, I use: lCurrentWidth = self.view.frame.size.width; lCurrentHeight = self.view.frame.size.height; in viewWillAppear: and willAnimateRotationToInterfaceOrientation:duration: The first…
griotspeak
  • 13,022
  • 13
  • 43
  • 54
492
votes
38 answers

iOS - Dismiss keyboard when touching outside of UITextField

I'm wondering how to make the keyboard disappear when the user touches outside of a UITextField.
jonepatr
  • 7,769
  • 7
  • 30
  • 53
391
votes
33 answers

How do you add multi-line text to a UIButton?

I have the following code... UILabel *buttonLabel = [[UILabel alloc] initWithFrame:targetButton.bounds]; buttonLabel.text = @"Long text string"; [targetButton addSubview:buttonLabel]; [targetButton bringSubviewToFront:buttonLabel]; ...the idea…
Owain Hunt
  • 4,619
  • 2
  • 20
  • 10
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
341
votes
42 answers

Move view with keyboard using Swift

I have an app that has a text field on the lower half of the view. This means that when I go to type in the text field the keyboard covers the textfield. How would I go about moving the view upwards while typing so I can see what i'm typing and then…
Alex Catchpole
  • 7,156
  • 6
  • 20
  • 29
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
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
312
votes
18 answers

How to capture UIView to UIImage without loss of quality on retina display

My code works fine for normal devices but creates blurry images on retina devices. Does anybody know a solution for my issue? + (UIImage *) imageWithView:(UIView *)view { UIGraphicsBeginImageContext(view.bounds.size); [view.layer…
Daniel
  • 3,331
  • 4
  • 19
  • 17
295
votes
6 answers

How to trap on UIViewAlertForUnsatisfiableConstraints?

I'm seeing an error appear in my debugger log: Will attempt to recover by breaking constraint Make a symbolic breakpoint at…
Maury Markowitz
  • 9,082
  • 11
  • 46
  • 98
289
votes
32 answers

Changing Placeholder Text Color with Swift

I have a design that implements a dark blue UITextField, as the placeholder text is by default a dark grey colour I can barely make out what the place holder text says. I've googled the problem of course but I have yet to come up with a solution…
Alex Catchpole
  • 7,156
  • 6
  • 20
  • 29
288
votes
15 answers

How to programmatically get iOS status bar height

I know that currently the status bar (with the time, battery, and network connection) at the top of the iPhone/iPad is 20 pixels for non-retina screens and 40 pixels for retina screens, but to future proof my app I would like to be able to determine…
lehn0058
  • 19,977
  • 15
  • 69
  • 109
1
2 3
99 100