cocoa-touch

Create a navigation button like the iPod "Now Playing" button

In the iPod app, there's a right-facing navigation button as well as the usual left-facing "Back" button. It gets you back to the "Now Playing" screen. Is this a custom button, or is there a way to easily create one using standard tools? ...

How to set a tint color for the section index of a UITableView?

Is there any way to customize the grey color of the alphabetic section index of a UITableView? ...

View queued events in iphone app's main runloop

Is there a way to display (via the debugger) which events are in queue for the main runloop of an iPhone app? ...

iPhone: no way to draw on screen outside drawRect?

Is there a way to draw on the iPhone screen (on a UIView in a UIWindow) outside of that view's drawRect() method? If so, how do I obtain the graphics context? The graphics guide mentions class NSGraphicsContext, but the relevant chapter seems like a blind copy/paste from Mac OS X docs, and there's no such class in iPhone SDK. EDIT: I'm...

iPhone keyboard, Done button and resignFirstResponder

This is probably a dumb question, but I can't find the answer in the docs. Did the "Done" button on the pop-up keyboard always cause the keyboard to disappear? I see a lot of code around the web like this: - (BOOL)textFieldShouldReturn:(UITextField *)theTextField { [theTextField resignFirstResponder]; return YES; } When I pres...

When using delegates, need better way to do sequential processing

I have a class WebServiceCaller that uses NSURLConnection to make asynchronous calls to a web service. The class provides a delegate property and when the web service call is done, it calls a method webServiceDoneWithXXX on the delegate. There are several web service methods that can be called, two of which are say GetSummary and GetLi...

Editing an UIImage

I have an UIImage that I want to edit (say, make every second row of pixels black). Now I am aware of the functions that extract PNG or JPEG data from the image, but that's raw data and I have no idea how the png/jpeg files work. Is there a way I can extract the colour data from each pixel into an array? And then make a new UIImage using...

iPhone - user interaction with programmatically added UIImageView

So I'm trying to add UIImageViews programatically (in this case I don't have the option of doing it in IB) and I want to be able to refer to them and manipulate them in the -touchesBegan and -touchesMoved methods. I've added the images like this: UIImageView *newPiece = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString s...

How can I replace a UITableViewController with a UIViewController that contains a UITableView?

I created a new SplitView iPad project in Xcode and setup the code to populate the TableView (in the RootView on the left) with data. Now I'd like to customize the RootView to contain a DatePicker view along with the TableView, but I'm unsure how to accomplish this. Since the default RootViewController is a subclass of a UITableViewCon...

Obtaining touch location for a uiscrollview touch

I have a uiscrollview as an element of a uiscrollviewcontroller, along with other view objects. The image scrolls and zooms as expected, when the scrollView is the top subview. However, I also need to get the screen location of the touch, in particular when there is no scroll action. (I understand the location may change during a scro...

How to manage memory load of static, lazily loaded dictionaries and arrays.

Generally, I use static arrays and dictionaries for containing lookup tables in my classes. However, with the number of classes creeping quickly into the hundreds, I'm hesitant to continue using this pattern. Even if these static collections are initialized lazily, I've essentially got a bounded memory leak going on as someone uses my ...

Performance issue finding weekdays over a given period

I have some methods that return the number of weekdays between two given dates. Since calling these methods become very expensive to call when the two dates lie years apart, I'm wondering how these methods could be refactored in a more efficient way. The returned result is correct but I feel that the iphone processor is struggling to ke...

UITouch Events and Table Views

I'm working on a navigation-based iPhone-only app that serves two main purposes: One, to present data in a hierarchical view, allowing users to drill down and eventually edit said data, and, two, to all users to perform a default action when the table view cell is tapped. I now need to offer a small set of options tied to the same data; ...

How can we access the variables declared in another class without using extern ?

Can we access the integer type variables in classB which are declared in classA by not using extern? For objects I used ClassA *obj1 = [[ClassA alloc]init]; And accessed the objects of classA into class B. But, I am not able to do them with the int , float, NSTimeInterval. How can we do for them without using extern ? Thank You....

How can I know which button I clicked to start an action inside the program?

I have 3 buttons which call the same function. I want to know inside the function which button called it. Is it possible to know it? ...

How do I start up an NSRunLoop, and ensure that it has an NSAutoreleasePool that gets emptied?

I have a "sync" task that relies on several "sub-tasks", which include asynchronous network operations, but which all require access to a single NSManagedObjectContext. Due to the threading requirements of NSManagedObjectContexts, I need every one of these sub-tasks to execute on the same thread. Due to the amount of processing being don...

UISegmentedControl - how to toggle between 2 UITableViews

I have a tab bar based application. What is the best way to toggle between 2 different UITableView views? Should I use a wrapper view and add those 2 views to it and depending on which segment was chosen I will show the correct view? Using only one tableView will not work because the layout is different between those 2 tableviews. Th...

Can I lock a UIWebView's orientation with Javascript or HTML?

I'm working on some HTML content as part of an iPad app. We may need to lock the content of the UIWebView to portrait mode, but the app has already been submitted to Apple and the only reference I've found to achieveing this is in this question which gives this example -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientatio...

Multiple taps with UITapGestureRecognizer

I have attached 3 tap gesture recognizers to the same view - single, double and triple tap. However, a double tap results in the single and double tap selector being called and the same for a triple tap. I expected that UITapGestureRecognizer class would have handled this situation appropriately. Does multiple tap gestures require additi...

initializer not constant?

Quick question if I may: I am just curious about the following (see below) Xcode says "initializer element is not constant" why this does not work, I guess its the NSArray ... static NSArray *stuffyNames = [NSArray arrayWithObjects:@"Ted",@"Dog",@"Snosa",nil]; and this does ... static NSString *stuffyNames[3] = {@"Ted",@"Dog",@"Snosa...