All Questions
Tagged with iphone objective-c
72,736
questions
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 ...
401
votes
34
answers
326k
views
How to dismiss keyboard for UITextView with return key?
In IB's library, the introduction tells us that when the return key is pressed, the keyboard for UITextView will disappear. But actually the return key can only act as '\n'.
I can add a button and ...
388
votes
7
answers
97k
views
UILongPressGestureRecognizer gets called twice when pressing down
I am detecting if the user has pressed down for 2 seconds:
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
initWithTarget:...
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.
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 ...
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 ...
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).
327
votes
15
answers
191k
views
How to hide 'Back' button on navigation bar on iPhone?
I added a navigation control to switch between views in my app. But some of the views shouldn't have 'Back' (the previous title) button. Any ideas about how to hide the back button?
324
votes
18
answers
203k
views
Detect current device with UI_USER_INTERFACE_IDIOM() in Swift
What is the equivalent of UI_USER_INTERFACE_IDIOM() in Swift to detect between iPhone and iPad?
I get an Use of unresolved identifier error when compiling in Swift.
319
votes
7
answers
165k
views
Why does viewWillAppear not get called when an app comes back from the background?
I'm writing an app and I need to change the view if the user is looking at the app while talking on the phone.
I've implemented the following method:
- (void)viewWillAppear:(BOOL)animated {
[...
317
votes
23
answers
244k
views
UITableview: How to Disable Selection for Some Rows but Not Others
I am displaying in a group tableview contents parsed from XML. I want to disable the click event on it (I should not be able to click it at all) The table contains two groups. I want to disable ...
302
votes
24
answers
156k
views
How to detect iPhone 5 (widescreen devices)?
I've just upgraded to Xcode 4.5 GM and found out that you can now apply the '4" Retina' size to your view controller in the storyboard.
Now if I want to create an application that runs on both ...
299
votes
10
answers
231k
views
How can we programmatically detect which iOS version is device running on? [duplicate]
I want to check if the user is running the app on iOS less than 5.0 and display a label in the app.
How do I detect which iOS is running on user's device programmatically?
Thanks!
293
votes
24
answers
255k
views
Proper way to exit iPhone application?
I am programming an iPhone app, and I need to force it to exit due to certain user actions. After cleaning up memory the app allocated, what's the appropriate method to call to terminate the ...
287
votes
6
answers
271k
views
String replacement in Objective-C
How to replace a character is a string in Objective-C?
285
votes
38
answers
226k
views
Detect if the device is iPhone X
My iOS app uses a custom height for the UINavigationBar which leads to some problems on the new iPhone X.
Does someone already know how to reliable detect programmatically (in Objective-C) if an app ...
281
votes
14
answers
215k
views
Cocoa Touch: How To Change UIView's Border Color And Thickness?
I saw in the inspector that I can change the background color, but I'd like to also change the border color and thickness, is this possible?
275
votes
7
answers
143k
views
How to store custom objects in NSUserDefaults
Alright, so I've been doing some poking around, and I realize my problem, but I don't know how to fix it. I have made a custom class to hold some data. I make objects for this class, and I need to ...
272
votes
23
answers
285k
views
How to get device make and model on iOS?
I was wondering if it's possible to determine what kind of iPhone (for example) the currentdevice is? I know it's possible to get the model through
NSString *deviceType = [[UIDevice currentDevice] ...
271
votes
6
answers
127k
views
Always pass weak reference of self into block in ARC?
I am a little confused about block usage in Objective-C. I currently use ARC and I have quite a lot of blocks in my app, currently always referring to self instead of its weak reference. May that be ...
270
votes
10
answers
557k
views
How much does it cost to develop an iPhone application? [closed]
How much can a developer charge for an iPhone app like Twitterrific?
I want to know this because I need such an application with the same functionality for a new community website. I can do Ruby but ...
248
votes
13
answers
149k
views
How to compare two NSDates: Which is more recent?
I am trying to achieve a dropBox sync and need to compare the dates of two files. One is on my dropBox account and one is on my iPhone.
I came up with the following, but I get unexpected results. I ...
248
votes
20
answers
142k
views
Make UINavigationBar transparent
How do you make a UINavigationBar transparent? Though I want its bar items to remain visible.
245
votes
35
answers
264k
views
Undefined symbols for architecture i386: _OBJC_CLASS_$_SKPSMTPMessage", referenced from: error
I have imported framework for sending email from application in background i.e. SKPSMTPMessage Framework. Can somebody suggest why below error is shown
Undefined symbols for architecture i386:
"...
245
votes
23
answers
309k
views
How to load a UIView using a nib file created with Interface Builder
I'm trying to do something a bit elaborate, but something that should be possible. So here is a challenge for all you experts out there (this forum is a pack of a lot of you guys :) ).
I'm creating a ...
242
votes
69
answers
622k
views
Apple Mach-O Linker Error when compiling for device
I've just upgraded to xcode 4.0 and I can no longer deploy to iPhone, I get a Apple Mach-O Linker Error, it still works for the simulator though.
Ld /Users/yveswheeler/Library/Developer/Xcode/...
239
votes
7
answers
92k
views
applicationWillEnterForeground vs. applicationDidBecomeActive, applicationWillResignActive vs. applicationDidEnterBackground
Which is the proper delegate to implement when an application is waking up from being in the background and you want it to prep it to be active?
applicationWillEnterForeground vs ...
239
votes
20
answers
272k
views
Get push notification while App in foreground iOS
I am using push notification service in my app. When app is in background I am able to see notification on notification screen(screen shown when we swipe down from top of iOS device). But if ...
237
votes
9
answers
140k
views
How can I use NSError in my iPhone App?
I am working on catching errors in my app, and I am looking into using NSError. I am slightly confused about how to use it, and how to populate it.
Could someone provide an example on how I populate ...
236
votes
11
answers
176k
views
iOS 7 Navigation Bar text and arrow color
I want to set background for Navigation Bar to be black and all colors inside it to be white.
So, I used this code :
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary ...
234
votes
23
answers
218k
views
How to deselect a selected UITableView cell?
I am working on a project on which I have to preselect a particular cell.
I can preselect a cell using -willDisplayCell, but I can't deselect it when the user clicks on any other cell.
- (void)...
230
votes
5
answers
209k
views
@property retain, assign, copy, nonatomic in Objective-C
As someone that's new to Objective-C can someone give me an overview of the retain, assign, copy and any others I'm missing, that follow the @property directive? What are they doing and why would I ...
229
votes
22
answers
140k
views
Stop UIWebView from "bouncing" vertically?
Does anyone know how to stop a UIWebView from bouncing vertically? I mean when a user touches their iphone screen, drags their finger downwards, and the webview shows a blank spot above the web page I ...
227
votes
19
answers
218k
views
Opening the Settings app from another app
Okay, I know that there are many question about it, but they are all from many time ago.
So. I know that it is possible because the Map app does it.
In the Map app if I turn off the localization for ...
220
votes
11
answers
111k
views
NSUserDefaults - How to tell if a key exists
I'm working on a small iPhone app, and I am using NSUserDefaults as my data persistence. It only has to keep track of a few things, such as some names and some numbers so I figure I might as well ...
219
votes
9
answers
153k
views
receiver type *** for instance message is a forward declaration
In my iOS5 app, I have NSObject States class, and trying to init it:
states = [states init];
here is init method in States:
- (id) init
{
if ((self = [super init]))
{
pickedGlasses =...
217
votes
13
answers
48k
views
iPad keyboard will not dismiss if modal ViewController presentation style is UIModalPresentationFormSheet
Note:
See accepted answer (not top voted one) for solution as of iOS 4.3.
This question is about a behavior discovered in the iPad keyboard, where it refuses to be dismissed if shown in a modal ...
214
votes
31
answers
149k
views
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 ...
214
votes
12
answers
318k
views
Setting an image for a UIButton in code
How do you set the image for a UIButton in code?
I have this:
UIButton *btnTwo = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btnTwo.frame = CGRectMake(40, 140, 240, 30);
[btnTwo setTitle:@"...
209
votes
5
answers
187k
views
How can I change UIButton title color?
I create a button programmatically..........
button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(aMethod:)
forControlEvents:UIControlEventTouchDown];
[...
203
votes
16
answers
95k
views
How can I click a button behind a transparent UIView?
Let's say we have a view controller with one sub view. the subview takes up the center of the screen with 100 px margins on all sides. We then add a bunch of little stuff to click on inside that ...
202
votes
3
answers
163k
views
@try - catch block in Objective-C
Why doesn't @try block work?
It crashed the app, but it was supposed to be caught by the @try block.
NSString* test = [NSString stringWithString:@"ss"];
@try {
[test characterAtIndex:6];
}
@...
201
votes
27
answers
109k
views
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 ...
201
votes
24
answers
225k
views
How do I URL encode a string
I have a URL string (NSString) with spaces and & characters. How do I url encode the entire string (including the & ampersand character and spaces)?
196
votes
13
answers
80k
views
UIButton inside a view that has a UITapGestureRecognizer
I have view with a UITapGestureRecognizer. So when I tap on the view another view appears above this view. This new view has three buttons. When I now press on one of these buttons I don't get the ...
195
votes
11
answers
188k
views
Xcode/Simulator: How to run older iOS version?
I'm thinking of upgrading to iOS SDK 4.2. But what I'm wondering is if I'll still be able to run the simulator as iOS 3.2. This is because I'm creating iAds for iPad but I still want to check if my ...
190
votes
17
answers
141k
views
Get UIScrollView to scroll to the top
How do I make a UIScrollView scroll to the top?
188
votes
27
answers
127k
views
Dashed line border around UIView
How do I add dashed line border around UIView.
Something Like this
185
votes
5
answers
138k
views
UIButton title text color
I'm setting text color for UIButton
headingButton.titleLabel.textColor = [UIColor colorWithRed:36/255.0
green:71/255.0
...