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
588
votes
21
answers
358k
views
Is it possible to disable the network in iOS Simulator?
I am trying to debug some inconsistent behaviour I am seeing in an application that gets its primary data from the Internet. I don't see the issues in the simulator, just on the device, so I'd like ...
585
votes
50
answers
325k
views
How can I create a UIColor from a hex string?
How can I create a UIColor from a hexadecimal string format, such as #00FF00?
582
votes
19
answers
295k
views
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.
577
votes
40
answers
808k
views
Create a rounded button / button with border-radius in Flutter
I'm currently developing an Android app in Flutter. How can I add a rounded button?
577
votes
23
answers
585k
views
Detect if device is iOS
I'm wondering if it's possible to detect whether a browser is running on iOS, similar to how you can feature detect with Modernizr (although this is obviously device detection rather than feature ...
575
votes
7
answers
473k
views
Convert UTF-8 encoded NSData to NSString
I have UTF-8 encoded NSData from windows server and I want to convert it to NSString for iPhone. Since data contains characters (like a degree symbol) which have different values on both platforms, ...
575
votes
11
answers
131k
views
Should IBOutlets be strong or weak under ARC?
I am developing exclusively for iOS 5 using ARC. Should IBOutlets to UIViews (and subclasses) be strong or weak?
The following:
@property (nonatomic, weak) IBOutlet UIButton *button;
Would get rid ...
571
votes
34
answers
567k
views
How do I create a basic UIButton programmatically?
How can I create a basic UIButton programmatically? For example in my view controller, when executing the viewDidLoad method, three UIButtons will be created dynamically and its layout or properties ...
570
votes
24
answers
234k
views
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 ...
568
votes
19
answers
692k
views
How to add constraints programmatically using Swift
I'm trying to figure this out since last week without going any step further. Ok, so I need to apply some constraints programmatically in Swift to a UIView using this code:
var new_view:UIView! = ...
567
votes
22
answers
1.0m
views
How can I add a border to a widget in Flutter?
I'm using Flutter and I'd like to add a border to a widget (in this case, a Text widget).
I tried TextStyle and Text, but I didn't see how to add a border.
565
votes
41
answers
431k
views
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:
...
564
votes
34
answers
292k
views
How do I get the App version and build number using Swift?
I have an IOS app with an Azure back-end, and would like to log certain events, like logins and which versions of the app users are running.
How can I return the version and build number using Swift?
560
votes
36
answers
747k
views
How would I create a UIAlertView in Swift?
I have been working to create a UIAlertView in Swift, but for some reason I can't get the statement right because I'm getting this error:
Could not find an overload for 'init' that accepts the ...
552
votes
31
answers
400k
views
How to set cornerRadius for only top-left and top-right corner of a UIView?
Is there a way to set cornerRadius for only top-left and top-right corner of a UIView?
I tried the following, but it end up not seeing the view anymore.
UIView *view = [[UIView alloc] initWithFrame:...
550
votes
32
answers
411k
views
How to determine the current iPhone/device model?
Is there a way to get the device model name (iPhone 4S, iPhone 5, iPhone 5S, etc) in Swift?
I know there is a property named UIDevice.currentDevice().model but it only returns device type (iPod touch,...
550
votes
17
answers
320k
views
Starting iPhone app development in Linux? [closed]
I've heard that you need to get a Mac if you want to develop iPhone apps. Is this true?
Is it possible to develop iPhone apps using Linux? If yes, what do I need and where do I download the ...
546
votes
18
answers
457k
views
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 ...
546
votes
18
answers
307k
views
How to programmatically send SMS on the iPhone?
Does anybody know if it's possible, and how, to programmatically send a SMS from the iPhone, with the official SDK / Cocoa Touch?
544
votes
87
answers
761k
views
Getting error "No such module" using Xcode, but the framework is there
I'm currently coding in Swift, and I've got an error:
No such module Social
But I don't understand, because the module is in my project, declared in "Linked frameworks and Libraries" and in "...
537
votes
50
answers
232k
views
How to hide UINavigationBar 1px bottom line
I have an app that sometimes needs its navigation bar to blend in with the content.
Does anyone know how to get rid of or to change color of this annoying little bar?
On the image below situation ...
530
votes
20
answers
308k
views
Take screenshots in the iOS simulator
I want to take a screenshot of my iOS application when it is running in the simulator, and save the screenshot on my Mac. How can I do this?
523
votes
14
answers
241k
views
How can I set the title of a UIButton as left-aligned?
I need to display an email address on the left side of a UIButton, but it is being positioned to the centre.
Is there any way to set the alignment to the left side of a UIButton?
This is my current ...
523
votes
12
answers
281k
views
Missing Compliance status in TestFlight
When I added my latest build for internal testing with TestFlight, I saw that it had a "Missing Compliance" status.
Is this a major problem? Why does this appear? How can I resolve this ...
521
votes
39
answers
751k
views
Loading/Downloading image from URL on Swift
I'd like to load an image from a URL in my application, so I first tried with Objective-C and it worked, however, with Swift, I've a compilation error:
'imageWithData' is unavailable: use object ...
513
votes
8
answers
156k
views
iPad Multitasking support requires these orientations
I'm trying to submit my universal iOS 9 apps to Apple (built with Xcode 7 GM) but I receive this error message for the bundle in iTunes Connect, just when I select Submit for Review:
Invalid Bundle. ...
511
votes
35
answers
223k
views
How to navigate through textfields (Next / Done Buttons)
How can I navigate through all my text fields with the "Next" Button on the iPhone Keyboard?
The last text field should close the Keyboard.
I've setup the IB the Buttons (Next / Done) but now I'm ...
511
votes
31
answers
166k
views
UIDevice uniqueIdentifier deprecated - What to do now?
It has just come to light that the UIDevice uniqueIdentifier property is deprecated in iOS 5 and unavailable in iOS 7 and above. No alternative method or property appears to be available or ...
509
votes
45
answers
503k
views
Close iOS Keyboard by touching anywhere using Swift
I have been looking all over for this but I can't seem to find it. I know how to dismiss the keyboard using Objective-C but I have no idea how to do that using Swift? Does anyone know?
504
votes
16
answers
141k
views
Codesign error: Provisioning profile cannot be found after deleting expired profile
Tried to rebuild an app that was working just yesterday. Got a message that a profile had expired, so I removed it from the iPod and from iTunes. When I chose a new profile (one with an * in the ...
504
votes
30
answers
150k
views
How to develop or migrate apps for iPhone 5 screen resolution?
The new iPhone 5 display has a new aspect ratio and a new resolution (640 x 1136 pixels).
What is required to develop new or transition already existing applications to the new screen size?
What ...
503
votes
25
answers
316k
views
Capture iOS Simulator video for App Preview
Okay, so we can now submit video previews of our apps on the App Store. According to Apple we should do so with an iOS8 device and OSX 10.10. The problem is you have to have all the different devices (...
496
votes
12
answers
217k
views
"Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo." when using GCC
While attempting to compile my C program, running the following command:
gcc pthread.c -o pthread
Returns:
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via ...
493
votes
38
answers
281k
views
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.
492
votes
30
answers
262k
views
Is it possible to opt-out of dark mode on iOS 13?
A large part of my app consists of web views to provide functionality not yet available through native implementations. The web team has no plans to implement a dark theme for the website. As such, my ...
492
votes
46
answers
305k
views
Set the maximum character length of a UITextField
How can I set the maximum amount of characters in a UITextField on the iPhone SDK when I load up a UIView?
492
votes
9
answers
134k
views
NSOperation vs Grand Central Dispatch
I'm learning about concurrent programming for iOS. So far I've read about NSOperation/NSOperationQueue and GCD. What are the reasons for using NSOperationQueue over GCD and vice versa?
Sounds like ...
488
votes
41
answers
285k
views
Fixing Xcode 9 issue: "iPhone is busy: Preparing debugger support for iPhone"
I'm looking for more information on the message below. Xcode 9 seems to be hanging for a couple minutes already...
How can I tell Xcode 9 to quickly recognize my previously used device updated to iOS ...
485
votes
9
answers
247k
views
How do I write dispatch_after GCD in Swift 3, 4, and 5?
In Swift 2, I was able to use dispatch_after to delay an action using grand central dispatch:
var dispatchTime: dispatch_time_t = dispatch_time(DISPATCH_TIME_NOW, Int64(0.1 * Double(NSEC_PER_SEC)))
...
484
votes
8
answers
123k
views
What does the "__block" keyword mean?
What exactly does the __block keyword in Objective-C mean? I know it allows you to modify variables within blocks, but I'd like to know...
What exactly does it tell the compiler?
Does it do anything ...
482
votes
26
answers
416k
views
Multiple lines of text in UILabel
Is there a way to have multiple lines of text in UILabel like in the UITextView or should I use the second one instead?
480
votes
20
answers
645k
views
How do you disable viewport zooming on Mobile Safari?
I've tried all three of these to no avail:
<meta name=”viewport” content=”width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;” />
<meta name=”viewport” content=”width=...
479
votes
14
answers
155k
views
This certificate has an invalid issuer Apple Push Services
I have created certificate to enable Push Services in my app, but every time I try to add certificate in my Keychain, after adding certificate it shows me following error:
This certificate has an ...
469
votes
23
answers
206k
views
Cocoapods Warning - CocoaPods did not set the base configuration of your project because because your project already has a custom config set
After I execute a pod install at the base of my project, I get the following error:
CocoaPods did not set the base configuration of your project because because your project already has a custom ...
469
votes
9
answers
199k
views
How do you beta test an iphone app?
How can you beta test an iPhone app? I can get it on my own device, and anyone that gives me a device, I can run it on theirs, but is there a way to do a limited release via the app store for beta ...
468
votes
59
answers
267k
views
dyld: Library not loaded: @rpath/libswiftCore.dylib
I am trying to run a Swift app on my iPhone 4s. It works fine on the simulator, and my friend can successfully run it on his iPhone 4s. I have iOS 8 and the official release of Xcode 6.
I have tried
...
468
votes
17
answers
141k
views
Error Running React Native App From Terminal (iOS)
I am following the tutorial on the official React Native website.
Using the following to build my project:
react-native run-ios
I get the error:
Found Xcode project TestProject.xcodeproj
xcrun: ...
468
votes
8
answers
446k
views
How do I load an HTTP URL with App Transport Security enabled in iOS 9? [duplicate]
So, the new beta SDK of iOS released last night has "App Transport Security" which encourages developers to use https instead of http. In principle, this is a great idea, and I already use https in ...
466
votes
25
answers
314k
views
How can I change image tintColor in iOS and WatchKit
I have an UIImageView called "theImageView", with UIImage in a single color (transparent background) just like the left black heart below. How can I change the tint color of this image ...
462
votes
17
answers
426k
views
NSNotificationCenter addObserver in Swift
How do you add an observer in Swift to the default notification center? I'm trying to port this line of code that sends a notification when the battery level changes.
[[NSNotificationCenter ...