cocoa-touch

Old views overlap the newer ones

Hi, am having the following problem: In my app I am creating a temporary object, for example a label in the following way: UILabel *tempLabel = [ [UILabel alloc] initWithFrame: CGRectMake(100, 5, 200, 30)]; tempLabel.backgroundColor = [UIColor colorWithRed: 1.0f green: 1.0f blue: 1.0f alpha: 0.0f]; tempLabel.text = [ [WordsDatabase sha...

What's a simple/fast way to display half-star ratings in an iphone view

I have a (float) rating value as a percentage from 0..100 (where 50 = Just OK, 0 = terrible and 100=best). What's a simple way to display this as a 5 star rating on the iphone, with the following requirements: simple (ideally just using drawing operations based on a png of a single star or five of them, and without needing to resort t...

How can I set the default state of a UISegmentedControl?

Is there a way to set the starting selected segment in a UISegmentedControl in Interface Builder, or do I have to do it in the code? If it's in the code, is viewDidLoad the best place to set it? ...

What's best practice for a long running operation that updates data in a currently displaying iphone tableview?

Background: I have a tableview displaying about 8 sections each backed with my own PlaceList class representing a list of objects (the implementation uses an NSMutableArray). There are around 200 objects in total. Each section corresponds to how far away the object is from the current location (e.g. within 1 mile, within 10, 25, 50...et...

Obj-C: C functions declared inside or outside @implementation block, what's the difference?

what's the difference between a C function (static or not) declared inside or outside the implementation block (@implementation ... @end) of a Objective-C class? is this specially true?: If you need to poke inside of the object directly, you can put this function inside of the @implementation block of your class, and then you can ac...

Storing a list of Categorize URLs - Sqlite DB, XML, or pList? Structure Design?

Hey guys, I want to store a categorized list of URLs. This is an internet radio streaming app, and so I want to have at least three links for each genre: the free streaming URL with commercials the premium streaming URL at 128 kbps the premium streaming URL at 256 kbps So every genre will have these three URLs. For the premium strea...

Detect double tap

Hi, How can I detect a double tap on a certain cell in UITableView? i.e. I want to perform one action if the user made a single touch and another if a user made a double touch? I also need to know an index path where the touch was made. How can I achieve this goal? Thanks. ...

NSTimer doesn't stop

Hi, I've got a timer which fires when viewWillAppear method is being called and invalidates when viewDidDisappear method is being called. But after a certain amount of switching between views the timer continues firing even after it was invalidated. What's the problem? Here is my code: NSTimer *timer; - (void)viewWillAppear:(BOOL)ani...

iPhone: Reusing UIViewControllers in order to save memory

Hi, what are best pratices to reuse UIViewControllers? In many apps (including Apple's own examples: e.g. SQLiteBooks), UIViewControllers are allocated and initialized everytime, a UIViewController is pushed to the stack. This increases the use of memory with every new controller, because the objects stay in memory and aren't used again...

How is a rounded rect view with transparency done on iphone?

A lot of apps pop up a transparent view with rounded corners and an activityIndicator when running a time consuming operation. How is this rounding done and is it possible to do it just using Interface Builder (as there are lots of places I'd like to use something like this)? Or, should I use an imageview with a rounded rect or stretcha...

NSNotification userinfo example?

I have an array of objects that are positioned using CGPoints . At certain times in my app, an object in the array needs to notify other non-arrayed objects of its position. I understand that NSNotification is the best way to go, but I cant find a decent example of a 'sender' and 'reciever' for the notification that wraps and unwraps a C...

How does one access a super's view controller?

Hi guys! I have a problem and I will try to explain the issue: I have one main UIViewController (Whole screen) I have one secondary UIViewController (setbounds) I added my secondary view to my mainview using this: [mainController.view addSubview:secondaryController.view]; I created a third controller: modalController, i added it to m...

Error saving data to cache directory (iPhone)

I am trying to save images using the following code: - (void)writeData{ if(cacheFileName==nil) return; if(cacheDirectoryPath==nil) return; if (![[NSFileManager defaultManager] fileExistsAtPath:[self filePath]]) { NSData *imageData = UIImageJPEGRepresentation(self.image, 0.9); NSEr...

How to keep the keyboard always on screen?

Hi, In a certain view I have got different elements and I need the keyboard to stay always on the screen. In iPhone OS 3.0, when touching text the keyboard gets dismissed sometimes. How can I keep it from dismissing? What is the best way to do so? Thanks. ...

How to use parametrized method with NSNotificationCenter?

I'd like to pass dict to the method processit. But once I access the dictionary, I get EXC__BAD_INSTRUCTION. NSNotificationCenter *ncObserver = [NSNotificationCenter defaultCenter]; [ncObserver addObserver:self selector:@selector(processit:) name:@"atest" object:nil]; NSDictionary *dict = [[NSDictionary alloc] ...

Play pure tones in Cocoa Touch

I've seen countless infos on how to play a sound file, but how can I generate a specific audio tone (or several) at given Hertz in cocoa touch? ...

NSURL analog to CFURLCreateCopyAppendingPathComponent?

Playing with URLs, more specifically building them incrementally from other, discovered URLs. In doing so, I'd like to stay using NSURL objects instead of manipulating NSStrings, just to gain the added sanity checks and url-specific methods from the URL class. Unfortunately, it seems that there is no way to get the following to join to...

Can UIViewAnimationTransitionCurlDown work on a view containing an image with transparency?

I am trying to animate a piece of text being pasted on to a view as a post-it note. I have a view with a yellow background, which contains a text view and a close button, initially set to be hidden. I animate it onto the main view like this: [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:postitView cache:NO]; p...

Change properties of UILabel in a TableViewCell

I have a tableView that's loosely based on the DetailViewController in ye olde SQLiteBooks. It's created programatically. Each cell displays a single value that when clicked displays a generic editingController that allows the user to edit that value. Pretty standard Cocoa-touch stuff... Except...I also have a segmented control in the ...

Hide an UITabBar when Orientation change

Hello, I have a quite simple question but the answer is not so easy. I want to hide a UITabBar when my orientation change. I looked 2 ways : Frame way myAppDelegate.tabBarController.tabBar.frame = CGRectMake(<<bottomOfScreen>>); Works fine but I have a blank area, so tried to play with tabBarController.view.frame et myViewControlle...