cocoa-touch

When i run my iPhone application it just show a white window, but when I press home button then it shows output what's wrong with it?

My piece of code is... window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; window.backgroundColor = [UIColor blackColor]; CGRect rect = CGRectMake(0,0,320,480); view = [ [ UIView alloc ] initWithFrame:rect ]; view.backgroundColor = [UIColor blueColor]; [window addSubview:view]; // Override point for customizat...

Can I detect if higher subview has been touched?

I've got a big UIView that responds to touches, and it's covered with lots of little UIViews that respond differently to touches. Is it possible to touch anywhere on screen and slide around, and have each view know if it's being touched? For example, I put my finger down on the upper left and slide toward the lower right. The touchesBe...

Is there an optimal way to render images in cocoa? Im using setNeedsDisplay.

Currently, any time I manually move a UIImage (via handling the touchesMoved event) the last thing I call in that event is [self setNeedsDisplay], which effectively redraws the entire view. My images are also being animated, so every time a frame of animation changes, i have to call setNeedsDisplay. I find this to be horrific since I d...

How to implement target-action-mechanism for custom control?

I'm going to write my own custom control that is very different from UIButton. It's so much different that I decided to write it from scratch. So all I subclass is UIControl. When my control is touched up inside, then I want to fire a message in means of target-action. The user of that class may instantiate it and then add some targets ...

Resizing UIViews

If I need to resize or reposition a UIView, is there a better way to do it than the following? view.frame = CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height - 100); Or in other words, is there a way to just say view.frame.size.height -= 100 through a non-readonly property? ...

Is calling -setNeedsDisplay from a background task asking for trouble?

I have a background task that updates a view. That task calls -setNeedsDisplay to have the view drawn. This works: - (void) drawChangesTask; { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; if (pixels) { drawChanges((UInt32 *) origPixels, (UInt32 *) pixels, CGBitmapContextGetBytesPerRow(ctx)/4, CGBitmapContex...

Replace UINavigation with UIToolbar?

I've built a Navigation-based app, but now that I'm knee-deep in the code, I've decided it would actually be best to have just a UIToolbar instead (only need modal views, not drill-downs). But extricating the Navigation stuff and replacing it with a Toolbar is causing me all sorts of grief... Has anyone ever done this, and maybe has a p...

iPhone dev - help with using Model

(By the way, I don't use Interface Builder) I have a little project consisting of a root UIViewController which manages 5 other View Controllers with a UITabBar, I'm not using UITabBarController. The Root View Controller only ever keeps one of its View Controllers instantiated, when a tab bar item is selected, the View Controller ...

How can I organise my resources into folders?

I'm working with a lot of files in my resources directory and I'd like to create folders to organise them. I've made a folder of plists, but I can't access it. Here's the code that works: NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"plist"]; and the code that doesn't work: NSString *path = [[NSBund...

MPMediaPickerControllerDelegate error

I get an error when trying to use MPMediaPickerControllerDelegate even though I have added the reference to the framework and added #import <MediaPlayer/MediaPlayer.h> The error I get is: "error: cannot find protocol declaration for 'MPMediaPickerControllerDelegate'" I'm trying to have a single binary work for iPhone OS 2.2 and 3.0,...

Alloted times for startup shutdown of iphone apps

How much time is given to the startup and shutdown of an iphone app (and possibly other important routines). I have had programs killed on my iphone by the OS which was overzealous? ...

Why doesn't NSEnumerator iterator recognize object properties within DrawRect?

I usually have no problems using NSEnumerator in the iPhone sdk but this is my first time using it within the DrawRect function of a UIView. The NSEnumerator iterator is causing an error: request for member "(member)" in something not a structure or union. 1) Why is this happening? 2) How can I workaround it? (P.S. the member not bei...

Rotate UIImageView and still get x/y click position

Hi, I have subclassed UIImageView to create a soccer ball. The ball bounces and moves along an x & y axis, and depending on where you touch the ball, the ball will move as you'd expect a soccer ball would. My problem is that I would like to rotate the Ball(UIImageView), but still know the x & y positions from it's original position. ...

How are touches handled by a UITableView?

I'm trying to better understand how UITableView and UITableViewCell work, and one part of that is touch handling. So when I touch a row on a table view, what exactly happens? My basic understanding is: UITableView is a UIScrollView, so first it checks if it's a touch or a scroll If it's not a scroll then the touch gets analyzed to see...

How to position this view relative to another?

Think about a speedometer, and imagine all these little strokes around it like 10 mph, 20 mph, 30 mph, and so on. I try to draw something similar. Imagine this: There are three views: A, B, C. A owns B owns C. C is a stroke on that speedometer. So to create it easily, there is view B inbetween which is exactly same size of A. First, ...

Adding Objects to an Objective C Array at Index

I have a synthesized NSMutableArray - theResultArray . I want to insert NSNumber or NSInteger objects at specific indexes (0-49). For some reason I can never get any values to stick in my array. Every index returns nil or 0. NSInteger timeNum = time; [theResultArray insertObject:[NSNumber numberWithInt:timeNum] atIndex:rightIn...

Setting a property on a custom object through Interface Builder

I have a custom UITableViewController subclass which I use in two places in a nib file. What should I do if I want the two instances to have slightly different behavior? Of course in the code I can select one kind of behavior or the other based on the value of a BOOL, but how do I set that BOOL from Interface Builder, without having to w...

Are keys and values in an NSDictionary ordered?

I mean: Is the order of keys and values in an NSDictionary always the same like how they were specified when initializing the NSDictionary? Or should I better maintain a seperate NSArray if I really need to know the order of keys? ...

How to drag, toss, animate a view along a curved path.

I have an view-based iPhone app. Currently there is a small image in the top left hand corner of the screen. When the user taps the screen the image is animated using a CAKeyframeAnimation along a curvy path to the lower right hand corner of the screen. Now I want to change the app so instead of animating on the tap event, the user can ...

How do I make sure that a tableViewController view takes up the full screen?

In the viewDidLoad method I add any combination of these and I can't get it to work: CGRect appFrame = [[UIScreen mainScreen] applicationFrame]; [[self tableView] setBounds:appFrame]; // self.view.frame = appFrame; // self.view.bounds = appFrame; // [[self tableVew] setFrame:appFrame]; self.view.autoresizingMask = UIViewAutoresizin...