cocoa-touch

touchesBegan & touchesMoved

So here's a weird question. I have a UIImageView that responds to touchesMoved & touchesBegan, it works perfectly. The main thing I'm having an issue with is if you put your finger down on say image1 and then with that finger still down on image1 you would press image2 with your other finger. In turn this would fire image1 again. Dont ...

How to set custom view for UIBarButtonItem?

I am trying to put a label in a UIBarButtonItem. Here is my viewDidLoad method: characterCountLabel = [[UILabel alloc] init]; characterCountLabel.text = @"HELLO"; charCountButton = [[UIBarButtonItem alloc]initWithCustomView:characterCountLabel]; Everything is hooked up properly in IB. Why is the label not appearing inside of my UIBarB...

iPhone: Handling touches transparently

I have a UIViewController and an associated with it UIView. The UIView has a number of subviews. How to handle touch event inside a specified rectangle in my UIViewController subclass? This handling should be transparent: UIView and its subviews should still receive their touch events even if they intersect with the specified rectangle...

Would I ever want to use any @property attributes other than "retain" and "nonatomic" for UI variables?

I'm diving into iOS development and I find that for each of my UI controls, I always just blindly declare their @property like so, since that's how it was done in some tutorial I read when I started learning... @property (retain, nonatomic) IBOutlet UILabel *lblStatus; I'm still getting familiar with these attribute types and what the...

how do i get the location of a touch in cocoa/objective-c?

I am looking to get the location of a touch, preferably corresponding to the pixels of the screen. I'm new to objective-c and cocoa and haven't been able to find anything on the web about this so i'm not sure if there is even a way to do it. any ideas or direction of where to look would be really helpful. thanks. ...

What could be wrong with my CGBitmapContextCreateImage() or UIGraphicsGetImageFromCurrentContext() call?

Same problem as this guy I'm trying to use CGBitmapContextCreateImage() or UIGraphicsGetImageFromCurrentContext(), but they leak badly, even if I don't do anything in the context. When I run this in a UIView subclass, before setNeedsDisplay: UIGraphicsBeginImageContext(CGSizeMake(320, 264)); // Optional drawing code here, but still lea...

How to save tab bar order when app is terminated?

The following example: http://www.raddonline.com/blogs/geek-journal/iphone-sdk-uitabbarcontroller-how-to-save-user-customized-tab-order/ Doesn't work in iOS4. I would like to be able to save the order of my tabs when the application is shut down. ...

UILongPressGestureRecognizer missing UIGestureRecognizerStateBegan state!

so I have implemented a 1-finger long-press gesture recognizer, but the recognizer always seems to be missing the UIGestureRecognizerStateBegan state... If I long press w/o moving finger and lift, I get the StateEnded debug message. If I long press and move finger a bit then lift, I get the StateChanged and StateEnded debug messages. But...

Does releasing a UIView release all its subviews?

If I have a UIView, and I add an allocated subview into it (in this case the UIImageView), when I release the UIView, will UIImageView also be released? I set up my view and a subview like this: UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; UIImage *myImage=[UIImage imageNamed:@"image.png"]; // This is the su...

Pass an int between a view and it's subview

I have a view called PatternsViewController and a subview named SolutionsViewController. I want to pass a variable in PatternsViewController named iteration to my SolutionsViewController, right before I present it with solutions = [[SolutionsViewController alloc] init]; solutions.modalTransitionStyle = UIModalTransitionStyleCrossDissolv...

setObject:forKey: method of NSMutableDictionary

Is the first parameter supposed to be an object? A tutorial I'm following has the first parameter being textFieldBeingEdited.text, where it is defined in the .h file as UITextField *textFieldBeingEdited Isn't textFieldBeingEdited an object, and text is a property of that object? The following code crashes: [tempValues setObject:tex...

Launch iPhone app automatically when it recieves remote notification

Hi all, Is it possible to launch iPhone application automatically when it receives remote notification whether it is closed or in the background? I would appreciate your help. Thanks in advance, Sarah ...

Add view to a navigation controller on app launch

I have an app that has a UITabBarController, one of the tabs of which is configured for a navigation controller. Based on certain logic I need to attach a different root view to the navigation controller inside the tab at application launch time. This is easily done in interface builder however, because I need to figure out what view t...

Replace Copy/Select popover when selecting text in UITextView

Is it possible to replace Copy/Select popover when selecting text in UITextView? When text is selected, I want my own view to pop over. ...

UIButton inside a view that has a UITapGestureRecognizer

I have view with a UITapGestureRecognizer. So when I tap on the view an other 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 buttons action, I only get the tap gesture action. So I'm not able to use these buttons anymore. What can I do to get the events through to t...

Emulating the camera apps 'tap to focus'

I am trying hard to emulate the basic functionality of the built in camera app. Thus far I have become stuck on the 'tap to focus' feature. I have a UIView from which I am collecting UITouch events when a single finger is tapped on the UIView. This following method is called but the camera focus & the exposure are unchanged. -(void)han...

iphone - performSelectorOnMainThread with return value

I have the following method: - (NSMutableArray *)getElements:(NSString *)theURL; And I wanted to know if there is a way to call that method using performSelectorOnMainThread so that I can get the return value. So far, I've tried with: myArray = [object performSelectorOnMainThread:@selector(getElements:) ...

Cococa Touch - Verifying each caracter inputed

I want to have the user type in something. And I want to verify each character inputed. How could I do this? I want it to be in real time. So as its typed its being verified and color coded. You could compare what I want to do to an programmers IDE how it checks the syntax as you type it. Any help is appreciated! ...

UIView Layout and applicationFrame

Hi everyone I am experiencing some weird behavior with my iPad app. I usually add a view to my viewController like this: CGRect bounds = [[UIScreen mainScreen] applicationFrame]; // Add Basic View UIView *myView = [[UIView alloc] initWithFrame:bounds]; myView.backgroundColor = [UIColor blackColor]; self.view = myView; [myView release];...

How can I center my image in horizontal orientation?

I have an image view that is inside of a UIScrollView so that I can pinch & zoom. My image looks fine in portrait mode, but when I go to horizontal orientation the image is not centered. The UIScrollView is 320x460. Here is my code: - (void)viewDidLoad { [super viewDidLoad]; CGRect frame = CGRectMake(0, 0, 320, 460); self...