All Questions
Tagged with iphone cocoa-touch
14,982
questions
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 ...
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:...
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 ...
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 ...
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] ...
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).
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!
294
votes
24
answers
182k
views
Creating a left-arrow button (like UINavigationBar's "back" style) on a UIToolbar
I'd love to create a "back" left-arrow-bezel button in a UIToolbar.
As far as I can tell, the only way to get one of these is to leave UINavigationController at default settings and it uses one for ...
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 ...
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?
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 ...
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 ...
243
votes
11
answers
166k
views
How can I send mail from an iPhone application
I want to send an email from my iPhone application. I have heard that the iOS SDK doesn't have an email API. I don't want to use the following code because it will exit my application:
NSString *url =...
241
votes
8
answers
147k
views
iPhone - Get Position of UIView within entire UIWindow
The position of a UIView can obviously be determined by view.center or view.frame etc. but this only returns the position of the UIView in relation to it's immediate superview.
I need to determine the ...
236
votes
17
answers
114k
views
Change font size of UISegmentedControl
Can anyone please tell me how can I change the font type and size of UISegmentedControl?
221
votes
7
answers
177k
views
Gradients on UIView and UILabels On iPhone [duplicate]
Possible Duplicate:
Manually drawing a gradient in iPhone apps?
My application needs to display text in either a UIView or UILabel but the back ground must be a gradient as opposed to a true ...
219
votes
5
answers
66k
views
How do I enter RGB values into Interface Builder?
How can I enter RGB or Hex color values for backgrounds in Interface Builder? I can select predefined colors but I would like to manually enter in RGB values. Where can I do this?
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 ...
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 ...
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 ...
199
votes
15
answers
167k
views
How to save picture to iPhone photo library?
What do I need to do to save an image my program has generated (possibly from the camera, possibly not) to the system photo library on the iPhone?
198
votes
24
answers
170k
views
Finding the direction of scrolling in a UIScrollView?
I have a UIScrollView with only horizontal scrolling allowed, and I would like to know which direction (left, right) the user scrolls. What I did was to subclass the UIScrollView and override the ...
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 ...
196
votes
19
answers
151k
views
Warning :-Presenting view controllers on detached view controllers is discouraged
In my app, I am using a navigation controller. Later on in some view I am using presentViewController for showing a zoomed image.
Also I am not using a Storyboard or nib.
I am getting this error in ...
192
votes
22
answers
200k
views
How do you dismiss the keyboard when editing a UITextField
I know that I need to tell my UITextField to resign first responder when I want to dismis the keyboard, but I'm not sure how to know when the user has pressed the "Done" key on the keyboard. Is there ...
191
votes
18
answers
197k
views
How to customize the background color of a UITableViewCell?
I would like to customize the background (and maybe the border too) of all of the UITableViewCells within my UITableView. So far I have not been able to customize this stuff, so I have a bunch of ...
191
votes
8
answers
129k
views
iOS: Multi-line UILabel in Auto Layout
I'm having trouble trying to achieve some very basic layout behavior with Auto Layout. My view controller looks like this in IB:
The top label is the title label, I don't know how many lines it will ...
190
votes
12
answers
147k
views
How can I scan barcodes on iOS? [closed]
How can I simply scan barcodes on iPhone and/or iPad?
183
votes
14
answers
241k
views
Launch an app from within another (iPhone)
Is it possible to launch any arbitrary iPhone application from within another app?, For example in my application if I want the user to push a button and launch right into the Phone app (close the ...
181
votes
29
answers
170k
views
Setting action for back button in navigation controller
I'm trying to overwrite the default action of the back button in a navigation controller. I've provided a target an action on the custom button. The odd thing is when assigning it though the ...
177
votes
5
answers
108k
views
What's the difference between using CGFloat and float?
I tend to use CGFloat all over the place, but I wonder if I get a senseless "performance hit" with this. CGFloat seems to be something "heavier" than float, right? At which points should I use CGFloat,...
171
votes
11
answers
181k
views
How can I delay a method call for 1 second?
Is there an easy way delay a method call for 1 second?
I have a UIImageView that reacts on a touch event. When the touch is detected, some animations happen in the app. After one second, I want to ...
170
votes
18
answers
201k
views
How to load local html file into UIWebView
I'm trying to load a html file into my UIWebView but it won't work. Here's the stage: I have a folder called html_files in my project. Then I created a webView in interface builder and assigned an ...
165
votes
18
answers
130k
views
Convert HTML to NSAttributedString in iOS
I am using a instance of UIWebView to process some text and color it correctly, it gives the result as HTML but rather than displaying it in the UIWebView I want to display it using Core Text with a ...
165
votes
4
answers
75k
views
Static table view outside UITableViewController
After the new Xcode update, my app doesn't validate and shows this error:
static table views are only valid when embedded in UITableViewController instances
Any chances to solve easily?
165
votes
4
answers
39k
views
What's the best way to communicate between view controllers?
Being new to objective-c, cocoa, and iPhone dev in general, I have a strong desire to get the most out of the language and the frameworks.
One of the resources I'm using is Stanford's CS193P class ...
164
votes
19
answers
132k
views
Disabled UIButton not faded or grey
In my iPhone app, I have a UIButton which I have created in Interface Builder. I can successfully enable and disable it like this in my code ...
sendButton.enabled = YES;
or
sendButton.enabled = NO;...
163
votes
11
answers
222k
views
Navigation bar show/hide
I have an app with a navigation bar consisting of 2 bar buttons. I would like to hide and show this navigation bar when a user double taps the screen.
Initially, the navigation bar should be hidden. ...
160
votes
15
answers
132k
views
UIButton: set image for selected-highlighted state
I set an images for button's states Normal,Highlighted and Selected, but when the button in selected state and I press/highlight it I didn't see my highlighted image but just grayed picture.
Is it ...
160
votes
5
answers
114k
views
UILabel - Wordwrap text
Is there any way to have a label wordwrap text as needed? I have the line breaks set to word wrap and the label is tall enough for two lines, but it appears that it will only wrap on line breaks. Do ...
157
votes
10
answers
72k
views
What's the point of NSAssert, actually?
I have to ask this, because: The only thing I recognize is, that if the assertion fails, the app crashes. Is that the reason why to use NSAssert? Or what else is the benefit of it? And is it right to ...
154
votes
19
answers
96k
views
Change Default Scrolling Behavior of UITableView Section Header
I have a UITableView with two sections. It is a simple table view. I am using viewForHeaderInSection to create custom views for these headers. So far, so good.
The default scrolling behavior is ...
154
votes
9
answers
136k
views
How to draw border around a UILabel?
Is there a way for UILabel to draw a border around itself? This is useful for me to debug the text placement and to see the placement and how big the label actually is.
149
votes
9
answers
108k
views
Adding the little arrow to the right side of a cell in an iPhone TableView Cell
This should be simple enough.
I have an iPhone app with a TableView. How do I add the little classic arrow to the righthand side of each cell?
142
votes
8
answers
214k
views
iPhone UIView Animation Best Practice
What is considered best practice for animating view transitions on the iPhone?
For example, the ViewTransitions sample project from apple uses code like:
CATransition *applicationLoadViewIn = [...
141
votes
7
answers
132k
views
Select tableview row programmatically
How do I programmatically select a UITableView row so that
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
gets executed? selectRowAtIndexPath ...
140
votes
25
answers
197k
views
How to automatically size UIScrollView to fit the content
Is there a way to make a UIScrollView auto-adjust to the height (or width) of the content it's scrolling?
Something like:
[scrollView setContentSize:(CGSizeMake(320, content.height))];
140
votes
8
answers
74k
views
UIWebView background is set to Clear Color, but it is not transparent
I'm developing an iOS 4 application using iOS SDK latest version and XCode 4.2.
I have a XIB with a UIWebView with Alpha = 1.0, Background set to Clear Color and Opaque is not set. On this XIB I ...
139
votes
10
answers
108k
views
Getting a list of files in a directory with a glob
For some crazy reason I can't find a way to get a list of files with a glob for a given directory.
I'm currently stuck with something along the lines of:
NSString *bundleRoot = [[NSBundle mainBundle]...
138
votes
13
answers
94k
views
viewWillDisappear: Determine whether view controller is being popped or is showing a sub-view controller
I'm struggling to find a good solution to this problem. In a view controller's -viewWillDisappear: method, I need to find a way to determine whether it is because a view controller is being pushed ...