Questions tagged [ios]
iOS is the mobile operating system running on the Apple iPhone, iPod touch, and iPad. Use this tag [ios] for questions related to programming on the iOS platform. Use the related tags [objective-c] and [swift] for issues specific to those programming languages.
687,448
questions
2340
votes
51
answers
764k
views
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 ...
1947
votes
28
answers
534k
views
What's the difference between the atomic and nonatomic attributes?
What do atomic and nonatomic mean in property declarations?
@property(nonatomic, retain) UITextField *userName;
@property(atomic, retain) UITextField *userName;
@property(retain) UITextField *...
1792
votes
99
answers
652k
views
How can I make a UITextField move up when the keyboard is present - on starting to edit?
With the iOS SDK:
I have a UIView with UITextFields that bring up a keyboard. I need it to be able to:
Allow scrolling of the contents of the UIScrollView to see the other text fields once the ...
1614
votes
29
answers
708k
views
Using Auto Layout in UITableView for dynamic cell layouts & variable row heights
How do you use Auto Layout within UITableViewCells in a table view to let each cell's content and subviews determine the row height (itself/automatically), while maintaining smooth scrolling ...
1601
votes
30
answers
959k
views
Transport security has blocked a cleartext HTTP
What setting do I need to put in my info.plist to enable HTTP mode as per the following error message?
Transport security has blocked a cleartext HTTP (http://) resource
load since it is insecure....
1500
votes
44
answers
524k
views
Passing data between view controllers
I'm new to iOS and Objective-C and the whole MVC paradigm and I'm stuck with the following:
I have a view that acts as a data entry form and I want to give the user the option to select multiple ...
1406
votes
39
answers
512k
views
How can I check for an active Internet connection on iOS or macOS?
I would like to check to see if I have an Internet connection on iOS using the Cocoa Touch libraries or on macOS using the Cocoa libraries.
I came up with a way to do this using an NSURL. The way I ...
1325
votes
27
answers
486k
views
How do I sort an NSMutableArray with custom objects in it?
What I want to do seems pretty simple, but I can't find any answers on the web. I have an NSMutableArray of objects, and let's say they are 'Person' objects. I want to sort the NSMutableArray by ...
1322
votes
82
answers
1.0m
views
Xcode - How to fix 'NSUnknownKeyException', Reason: "… this class is not key value coding-compliant for the key X" error?
I'm trying to link a UILabel with an IBOutlet created in my class.
My application is crashing with the following error"
***
Terminating app due to uncaught exception
'NSUnknownKeyException', ...
1304
votes
19
answers
191k
views
performSelector may cause a leak because its selector is unknown
I'm getting the following warning by the ARC compiler:
"performSelector may cause a leak because its selector is unknown".
Here's what I'm doing:
[_controller performSelector:NSSelectorFromString(@"...
1282
votes
21
answers
586k
views
How do I check if a string contains another string in Objective-C?
How can I check if a string (NSString) contains another smaller string?
I was hoping for something like:
NSString *string = @"hello bla bla";
NSLog(@"%d",[string containsSubstring:@"hello"]);
But ...
1278
votes
42
answers
540k
views
How can I disable the UITableView selection?
When you tap a row in a UITableView, the row is highlighted and selected. Is it possible to disable this so tapping a row does nothing?
1270
votes
42
answers
1.1m
views
How can I develop for iPhone using a Windows development machine?
Is there any way to tinker with the iPhone SDK on a Windows machine? Are there plans for an iPhone SDK version for Windows?
The only other way I can think of doing this is to run a Mac VM image on a ...
1153
votes
37
answers
572k
views
How can I change the name of an iOS app in Xcode?
I began an iPhone project the other day with a silly development code name, and now I want to change the name of the project since it's nearly finished. How can I do this?
1087
votes
61
answers
672k
views
How to change Status Bar text color in iOS
My application has a dark background, but in iOS 7 the status bar became transparent. So I can't see anything there, only the green battery indicator in the corner. How can I change the status bar ...
1049
votes
12
answers
338k
views
How do I animate constraint changes?
I'm updating an old app with an AdBannerView and when there is no ad, it slides off screen. When there is an ad it slides on the screen. Basic stuff.
Old style, I set the frame in an animation block.
...
1048
votes
14
answers
447k
views
Constants in Objective-C
I'm developing a Cocoa application, and I'm using constant NSStrings as ways to store key names for my preferences.
I understand this is a good idea because it allows easy changing of keys if ...
950
votes
14
answers
465k
views
How do I convert an NSString value to NSData?
How do I convert an NSString value to NSData?
922
votes
66
answers
777k
views
Xcode building for iOS Simulator, but linking in an object file built for iOS, for architecture 'arm64'
I am trying to get a large (and working on Xcode 11!) project building in Xcode 12 (beta 5) to prepare for iOS 14. The codebase was previously in Objective-C, but now it contains both Objective-C and ...
909
votes
36
answers
531k
views
How to check iOS version?
I want to check if the iOS version of the device is greater than 3.1.3
I tried things like:
[[UIDevice currentDevice].systemVersion floatValue]
but it does not work, I just want a:
if (version > ...
909
votes
25
answers
554k
views
Xcode error "Could not find Developer Disk Image"
When attempting to run a build on a connected iOS device in Xcode I get the error:
Could not find Developer Disk Image
I saw that there was a public beta for Xcode, so I installed it.
One of the ...
857
votes
11
answers
172k
views
Xcode 7 error: "Missing iOS Distribution signing identity for ..."
I tried to upload my App to iTunes Connect resp. AppStore and got the following error:
Failed to locate or generate matching signing assets
Xcode attempted to locate or generate matching signing ...
832
votes
19
answers
279k
views
Xcode 6: Keyboard does not show up in simulator
The keyboard does not show up when I run the simulator and click in the UITextView. How do I re-enable the keyboard?
It used to work but now it doesn't - I don't know what I might have clicked by ...
819
votes
33
answers
296k
views
Loaded nib but the 'view' outlet was not set
I added a new nib file to my project, and tried to load it.
However, when I click on the toolbar icon that is supposed to take me to the view that I created, I get an NSInternalInconsistencyException ...
793
votes
14
answers
145k
views
Xcode process launch failed: Security
I have been developing an app for 1 or 2 weeks now and just yesterday I have updated my iPhone 5S to the iOS 8 GM. Everything worked fine and I could test on my device as well until I deleted the app ...
792
votes
32
answers
241k
views
Can I embed a custom font in an iPhone application?
I would like to have an app include a custom font for rendering text, load it, and then use it with standard UIKit elements like UILabel. Is this possible?
776
votes
20
answers
399k
views
How do you trigger a block after a delay, like -performSelector:withObject:afterDelay:?
Is there a way to call a block with a primitive parameter after a delay, like using performSelector:withObject:afterDelay: but with an argument like int/double/float?
774
votes
20
answers
385k
views
How do I create delegates in Objective-C?
I know how delegates work, and I know how I can use them.
But how do I create them?
771
votes
34
answers
200k
views
Eliminate extra separators below UITableView
When I set up a table view with 4 rows, there are still extra separators lines (or extra blank cells) below the filled rows.
How would I remove these cells?
769
votes
14
answers
236k
views
Hide strange unwanted Xcode logs
When using the Xcode 8+ and creating a new blank project, the following logs appear when running the application:
2016-06-13 16:33:34.406093 TestiOS10[8209:100611] bundleid: com.appc.TestiOS10, ...
769
votes
28
answers
816k
views
How to link to apps on the app store
I am creating a free version of my iPhone game. I want to have a button inside the free version that takes people to the paid version in the app store. If I use a standard link
http://itunes.apple....
754
votes
63
answers
392k
views
Placeholder in UITextView
My application uses an UITextView. Now I want the UITextView to have a placeholder similar to the one you can set for an UITextField.
How to do this?
731
votes
78
answers
323k
views
Why is there extra padding at the top of my UITableView with style UITableViewStyleGrouped in iOS7
Starting in iOS7, there is additional space at the top of my UITableView's which have a style UITableViewStyleGrouped.
Here is an example:
The tableview starts at the first arrow, there are 35 pixels ...
710
votes
45
answers
196k
views
This action could not be completed. Try Again (-22421)
I am trying to upload an Apple TV App to the App Store for testing purposes, but I got the issue:
This Action could not be completed. Try Again (-22421)
as in the below image:
So what can I do?
706
votes
7
answers
186k
views
Version vs build in Xcode
I have an app that I developed with Xcode 3 and recently started editing with Xcode 4. In the target summary I have the iOS application target form with fields: identifier, version, build, devices, ...
690
votes
30
answers
297k
views
How do I test if a string is empty in Objective-C?
How do I test if an NSString is empty in Objective-C?
686
votes
43
answers
188k
views
iOS 8 UITableView separator inset 0 not working
I have an app where the UITableView's separator inset is set to custom values - Right 0, Left 0. This works perfectly in iOS 7.x, however in iOS 8.0 I see that the separator inset is set to the ...
671
votes
38
answers
438k
views
Attempt to present UIViewController on UIViewController whose view is not in the window hierarchy
Just started using Xcode 4.5 and I got this error in the console:
Warning: Attempt to present < finishViewController: 0x1e56e0a0 > on < ViewController: 0x1ec3e000> whose view is not in the ...
670
votes
34
answers
355k
views
iOS app with framework crashed on device, dyld: Library not loaded, Xcode 6 Beta
This crash has been a blocking issue I used the following steps to reproduce the issue:
Create a Cocoa Touch Framework project
Add a swift file and a class Dog
Build a framework for device
Create a ...
656
votes
9
answers
177k
views
What does the NS prefix mean?
Many classes in Cocoa/Cocoa Touch have the NS prefix. What does it mean?
649
votes
28
answers
345k
views
Presenting modal in iOS 13 fullscreen
In iOS 13 there is a new behaviour for modal view controller when being presented.
Now it's not fullscreen by default and when I try to slide down, the app just dismiss the View Controller ...
641
votes
22
answers
420k
views
UITextField text change event
How can I detect any text changes in a textField? The delegate method shouldChangeCharactersInRange works for something, but it did not fulfill my need exactly. Since until it returns YES, the ...
639
votes
52
answers
235k
views
Xcode 6 Bug: Unknown class in Interface Builder file
I upgraded to Xcode 6 beta 4 and now my App continuously crashes with the message
Unknown class X in Interface Builder file.
It crashes because supposedly Xcode can't find my custom classes that I ...
637
votes
18
answers
306k
views
How to tell if UIViewController's view is visible
I have a tab bar application, with many views. Is there a way to know if a particular UIViewController is currently visible from within the UIViewController? (looking for a property)
633
votes
6
answers
415k
views
Send and receive messages through NSNotificationCenter in Objective-C?
I am attempting to send and receive messages through NSNotificationCenter in Objective-C. However, I haven't been able to find any examples on how to do this. How do you send and receive messages ...
625
votes
35
answers
366k
views
UIScrollView Scrollable Content Size Ambiguity
Fellow devs,
I am having trouble with AutoLayout in Interface Builder (Xcode 5 / iOS 7).
It's very basic and important so I think everyone should know how this properly works. If this is a bug in ...
614
votes
21
answers
396k
views
Giving UIView rounded corners
My login view has a subview which has a UIActivityView and a UILabel saying "Signing In…". This subview has corners which aren't rounded. How can I make them round?
Is there any way to do it inside ...
612
votes
27
answers
383k
views
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection
I am facing the Problem when I have updated my Xcode to 7.0 or iOS 9.0.
Somehow it started giving me the Titled error
"The resource could not be loaded because the App Transport Security
policy ...
606
votes
6
answers
240k
views
What are Unwind segues for and how do you use them?
iOS 6 and Xcode 4.5 has a new feature referred to as "Unwind Segue":
Unwind segues can allow transitioning to existing instances of scenes in a storyboard
In addition to this brief entry in Xcode ...
598
votes
32
answers
385k
views
iPhone UITextField - Change placeholder text color
I'd like to change the color of the placeholder text I set in my UITextField controls, to make it black.
I'd prefer to do this without using normal text as the placeholder and having to override all ...