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,253
questions
379
votes
3
answers
104k
views
Fast and Lean PDF Viewer for iPhone / iPad / iOS - tips and hints?
There has been many Questions recently about drawing PDF's.
Yes, you can render PDF's very easily with a UIWebView but this cant give the performance and functionality that you would expect from a ...
376
votes
31
answers
199k
views
Determine device (iPhone, iPod Touch) with iOS
Is there a way to determine the device running an application. I want to distinguish between iPhone and iPod Touch, if possible.
375
votes
10
answers
315k
views
Remove or uninstall library previously added : cocoapods
I added an external framework via cocoapods into my iOS application. How can i remove that library from the project?
374
votes
4
answers
94k
views
How to write iOS app purely in C
I read here Learn C Before Objective-C?
Usually I then replace some Obj-C code with pure C code (after all you can mix them as much as you like, the content of an Obj-C method can be entirely, pure ...
373
votes
15
answers
191k
views
Global constants file in Swift
In my Objective-C projects I often use a global constants file to store things like notification names and keys for NSUserDefaults. It looks something like this:
@interface GlobalConstants : NSObject
...
372
votes
31
answers
130k
views
Error when testing on iOS simulator: Couldn't register with the bootstrap server
I was testing my app on the simulator when it crashed on clicking a button of a UIAlertView. I stopped debugging there, made some changes to the code and built the app again. Now when I run the ...
371
votes
10
answers
158k
views
How to remove empty cells in UITableView? [duplicate]
i am trying to display a simple UITableView with some data. I wish to set the static height of the UITableView so that it doesn't displays empty cells at the end of the table. how do I do that?
code:
...
370
votes
6
answers
172k
views
Proper way to renew distribution certificate for iOS
My distribution certificate is expiring on June 7th, along with all of my provisioning files. How do I properly renew it? Should I revoke it now and request a new one? If I do that than will all my ...
369
votes
21
answers
361k
views
How do I check when a UITextField changes?
I am trying to check when a text field changes, equivalent too the function used for textView - textViewDidChange so far I have done this:
func textFieldDidBeginEditing(textField: UITextField) {
...
368
votes
13
answers
203k
views
How do I fix the xcrun unable to find simctl error?
I have Xcode 6.2 Beta. Attempting
xcrun simctl
in terminal yields
xcrun: error: unable to find utility "simctl", not a developer tool or in PATH
367
votes
24
answers
214k
views
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 ...
366
votes
29
answers
428k
views
The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1
I'm getting this below warning message in my Xcode 10.1.
The iOS Simulator deployment targets are set to 7.0, but the range of supported deployment target versions for this platform is 8.0 to 12.1.
...
365
votes
60
answers
412k
views
Error: "The sandbox is not in sync with the Podfile.lock..." after installing RestKit with cocoapods
I've encountered an strange issue after installing RestKit with cocoapods.
after resolving RestKit dependency for my project with cocoapods and trying to build it, I face this error:
The sandbox is ...
362
votes
48
answers
213k
views
Xcode error: Failed to prepare device for development
I have updated to Xcode 12.3 beta. device version is 14.2, but Xcode complaining:
Errors were encountered while preparing your device for development. Please check the Devices and Simulators Window.
...
362
votes
6
answers
196k
views
What are my options for storing data when using React Native? (iOS and Android) [closed]
I am still new in the React Native world, and generally in the mobile/native world as well, and I am finding the documentation a bit lacking when it comes to data persistence.
What are my options for ...
360
votes
10
answers
357k
views
How to pass prepareForSegue: an object
I have many annotations in a mapview (with rightCalloutAccessory buttons). The button will perform a segue from this mapview to a tableview. I want to pass the tableview a different object (that ...
358
votes
16
answers
258k
views
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 ...
358
votes
14
answers
315k
views
Generate JSON string from NSDictionary in iOS
I have a dictionary I need to generate a JSON string by using dictionary. Is it possible to convert it? Can you guys please help on this?
358
votes
6
answers
93k
views
UIButton remove all target-actions
I have added multiple target-action-forControlEvents: to a UIButton. I'd like to remove all of these in one go without deallocating anything. I will then set new targets.
Is this possible and how do ...
355
votes
15
answers
58k
views
After upgrading to Xcode 11.2 from Xcode 11.1, app crashes due to _UITextLayoutView
After upgrading to Xcode 11.2 from Xcode 11.1 my app crashes:
*** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named ...
354
votes
21
answers
139k
views
How to detect if app is being built for device or simulator in Swift
Note, extremely old historic QA.
(Is now just #if targetEnvironment(simulator).)
In Objective-C we can know if an app is being built for device or simulator using macros:
#if TARGET_IPHONE_SIMULATOR
...
352
votes
34
answers
279k
views
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.
352
votes
33
answers
216k
views
I get conflicting provisioning settings error when I try to archive to submit an iOS app
Now I'm trying to Product>Archive my iOS app to submit. However, I am getting following errors:
AppName has conflicting provisioning settings. AppName is automatically signed for development, but ...
351
votes
18
answers
388k
views
Instantiate and Present a viewController in Swift
Issue
I started taking a look on the Swift Programming Language, and somehow I am not able to correctly type the initialization of a UIViewController from a specific UIStoryboard.
In Objective-C I ...
349
votes
15
answers
335k
views
SwiftUI text-alignment
Among the many properties of the Text view, I couldn't find any related to text alignment. I've seen in a demo that it automatically handles RTL, and when placing stuff using View's body, it always ...
349
votes
20
answers
146k
views
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] ...
349
votes
18
answers
171k
views
How to disable back swipe gesture in UINavigationController on iOS 7
In iOS 7 Apple added a new default navigation behavior. You can swipe from the left edge of the screen to go back on the navigation stack. But in my app, this behavior conflicts with my custom left ...
349
votes
8
answers
140k
views
When to use NSInteger vs. int
When should I be using NSInteger vs. int when developing for iOS? I see in the Apple sample code they use NSInteger (or NSUInteger) when passing a value as an argument to a function or returning a ...
348
votes
42
answers
191k
views
library not found for -lPods
I got an error when archiving a project. This is my environment.
Mac OS Lion
Xcode 4.3.1
iOS SDK 5.1
The project deployment target is:
IPHONEOS_DEPLOYMENT_TARGET 3.2
The error shows:
ld: library ...
348
votes
44
answers
294k
views
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 ...
348
votes
7
answers
232k
views
Convert an NSURL to an NSString
I have an app where the user can choose an image either from the built-in app images or from the iphone photo library. I use an object Occasion that has an NSString property to save the imagePath.
...
348
votes
10
answers
99k
views
Create singleton using GCD's dispatch_once in Objective-C
If you can target iOS 4.0 or above
Using GCD, is it the best way to create singleton in Objective-C (thread safe)?
+ (instancetype)sharedInstance
{
static dispatch_once_t once;
static id ...
347
votes
12
answers
271k
views
Can I safely delete contents of Xcode Derived data folder?
I am running low on disk space and checked through a third party utility that among other things that ~/Library/Developer/Xcode/DerivedData directory is taking about 22GB of disk space.
I searched ...
346
votes
33
answers
124k
views
What are best practices that you use when writing Objective-C and Cocoa? [closed]
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).
346
votes
37
answers
139k
views
App installation failed due to application-identifier entitlement
I am unable to install a watchOS 2 WatchKit app due to an application-identifier entitlement. This happened after turning on App Groups in the Capabilities tab.
Full error:
App installation failed
...
346
votes
17
answers
127k
views
How do I detect when someone shakes an iPhone?
I want to react when somebody shakes the iPhone. I don't particularly care how they shake it, just that it was waved vigorously about for a split second. Does anyone know how to detect this?
345
votes
34
answers
376k
views
UITableView Cell selected Color?
I have created a custom UITableViewCell. The table view is showing data fine. What I am stuck in is when user touches cell of tableview, then I want to show the background color of the cell other than ...
344
votes
17
answers
276k
views
iPhone App Icons - Exact Radius?
I'm trying to create the icon for my iPhone app, but don't know how to get the exact radius that the iPhone's icons use. I've searched and searched for a tutorial or a template but can't find one.
I'...
343
votes
22
answers
239k
views
Color Tint UIButton Image
I noticed that when I place a white or black UIImage into a UISegmentedControl it automatically color masks it to match the tint of the segmented control. I thought this was really cool, and was ...
343
votes
8
answers
96k
views
Emulating aspect-fit behaviour using AutoLayout constraints in Xcode 6
I want to use AutoLayout to size and layout a view in a manner that is reminiscent of UIImageView's aspect-fit content mode.
I have a subview inside a container view in Interface Builder. The subview ...
343
votes
22
answers
295k
views
Programmatically create a UIView with color gradient
I'm trying to generate a view with a gradient color background (A solid color to transparent) at runtime. Is there a way of doing that?
342
votes
50
answers
327k
views
How do you debug React Native?
How does one debug their React code with React Native while the app is running in app simulator?
341
votes
31
answers
255k
views
UIScrollView scroll to bottom programmatically
How can I make a UIScrollView scroll to the bottom within my code? Or in a more generic way, to any point of a subview?
340
votes
14
answers
73k
views
iPhone Simulator suddenly started running very slow
I have been working on an app in iphone simulator for a number of weeks and it has been running well up until now, but all of a sudden has begun running very slow both when loading content and ...
339
votes
9
answers
236k
views
Programmatically get own phone number in iOS
Is there any way to get own phone number by standard APIs from iPhone SDK?
338
votes
13
answers
67k
views
Best architectural approaches for building iOS networking applications (REST clients) [closed]
I'm an iOS developer with some experience and this question is really interesting to me. I saw a lot of different resources and materials on this topic, but nevertheless I'm still confused. What is ...
336
votes
8
answers
191k
views
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 ...
334
votes
38
answers
318k
views
UILabel text margin [duplicate]
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 ...
334
votes
4
answers
118k
views
What's the difference between all the Selection Segues?
Show
Show Detail
Present Modally
Popover presentation
Custom
What is the difference between them? I couldn't find any documentation on it. There used to be some which I found in a Google search, but ...
333
votes
17
answers
100k
views
"Warning: iPhone apps should include an armv6 architecture" even with build config set
It's been a while since I've had to adjust project build settings. After upgrading to a recent SDK I'm having trouble building my ad hoc distribution configuration.
Build generates this warning and ...