cocoa-touch

How would i load a xib when device orientation is changed in xcode?

how would i go about loading a new xib when the orientation of the device is changed? i.e. load a landscape oriented xib when the device is turned into landscape orientation and vice-versa with portrait. and how would i go about automatically detecting an orientation change and adjusting from there? ...

What's a suitable cross-platform methodology for iOS and Mac OS X?

There seem to be lots of answers for cross-platform frameworks for devices (iPhone + Android), and cross-platform frameworks for desktops (Mac + Win + Linux). This is a different question regarding a suitable framework, methodology, template app, tutorial, or just helpful hints, on developing native apps (not just web apps) that are cro...

NSURLConnection and keep-alive

I have a small bug in my client app that uses NSURLConnection. I have tracked it down to an unexpected connection keep-alive that seems to confuse the web server (probably a bug on the server side). The workaround would be to force-close all outstanding connections at a certain point. Can I do this somehow with NSURLConnection, i.e. some...

Autorotation in UINavigationController

There're an UINavigationController with rootViewController (as root) and secondViewController (as a child). The rootViewController should be able to rotate to any orientation (that works as expected, I just override the shouldAutorotateToInterfaceOrientation), but the secondViewController should work in Portrait mode only (here, I set th...

CFStream: User-friendly errors

I need to connect to a remote host and exchange data with some binary protocol. I'm connecting with: CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)@"whatever.host.com", port, &readStream, &writeStream); Everything is fine, except the error handling. I'm handling NSStreamEventErrorOccurred in my stream's delegate...

creating an infinite stack of UIImageviews in xcode

i am trying to create a stack of UIImageViews in my app where i can indefinitely touch the uiimageview move it around the screen and drop it anywhere and there would still be a representation of the UIImageview in the original location where i could go grab another uiimageview move it and so on.the way i was trying to solve this problem ...

How to get the location of a touch in touchesBegan function

I tried the following code, but it doesn't work. How should it be modified? - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { location = [touches locationInView:self]; } In the h files I have defined location like this: CGPoint location; ...

UIDeviceOrientation *orientation = [UIDevice currentDevice].orientation; gets an 'incomplatible types in intialization' error

can anyone tell me why this line would throw an incompatible types error? UIDeviceOrientation *orientation = [UIDevice currentDevice].orientation; ...

iPhone - Linking touch events to different classes/controllers

I have a UISlider inside a custom UITableViewCell named SliderCell. I have a method in SliderCell which updates a UILabel to match the slider's value. - (IBAction)sliderChanged:(id)sender; I have the same method in a viewController that uses SliderCell in it's table. Base on the value of the slider, I want to reload an NSDictionary. ...

dynamically creating UIImageViews in a custom class method call in xcode

i want to dynamically create and add to the view a uiimageview when a touch is registered within the frame of another uiimageview. i want these to stay on the screen and remain moveable when a touch is registered inside the frame of each uiimageview. here is the code i have now but it doesn't quite work right and is really glitchy(i.e. i...

How to highlight a button when it is pressed

This seems to work, but then the program crashes right after the button get highlighted. -(IBAction) buttonPressed: (id) sender { [sender setHighlighted:YES]; } How should this be diffeent? What would it look like if I wanted to highlight the button if it was not previously highlighted, and return the button to its normal stat...

Do something else instead of using the keyboard with a UITextField

When the UITextField is selected a keyboard popups up. Can this behavior be modified so that instead it loads a different view? ...

How to return to the main view in a tab bar application

In a tab bar application I made a view controller for the second view. I put in an IBOutlet that is attached to a button. When the button is pressed, I want to return to the main view. This is what I put, but it crashes. -(IBAction) cancel { [self.view removeFromSuperview]; } How should this be changed? ...

AppDelegate protocol

Hi! i've implemented a transition methood in my app delegate file and from every where in the code i want to call it in order to make nice and cool transitions. i call her like that [[[UIApplication sharedApplication] delegate] transFromMainToGalery]; for example. the problem is that im getting warning which is ok (cause it alrea...

How to get the current working directory's absolute path in Objective-C?

How do I get the current working directory's absolute path on the iPhone using Objective-C? ...

NSFileManager fileExistsAtPath: & symbolic links

In my ~/Library/Caches/ directory, I have a symbolic link to my app's bundle, and some symbolic links to images (e.g. "big_picture.png" is a symlink to "small_picture.png"). When I try to check if the symlinks exist, using the NSFileManager's fileExistsAtPath: method, it returns NO, even when the symlink does exist, and it links to a fil...

Cocoa Touch - keyboard keeps hiding itself

I am trying to move my view when the user selects a text field so that the text field is still visible, which I have achieved. I am also using a control event to ensure that the text field is not empty before enabling a button. Using [longTextField addTarget:self action:@selector(updateAnswerButtonEnabled:) forControlEvents:UIControlEv...

NSUndoManager stops undoing in certain conditions

Im trying to implement an undo manager in my app using Core Data. Instead of making my own UndoManager im using the default undo manager in my ManagedObjectContext. Because of that i am not registering any actions manually, neither am i beginning or ending any undo groups. Undo works fine for most conditions however at certain conditions...

How do I get Core Data to use my own NSManagedObjectID URI scheme?

I am writing an app that connects to a database to fetch data. Since the fetching is expensive and the data is generally unchanging, I'm using CoreData to cache the results so that I can do fast, local queries. From the database, for each type, there is a string property that is guaranteed to be unique. In fact, there is a URI scheme fo...

Handling touch event logic in Subview or ViewController

I have a series of UIView subclasses that are added as subviews. Each subview can be dragged and dropped. When they are dropped (touchesEnded), I need to run a method in the viewController to do some work. I currently have the touchEvents handled in each subview class. Should I be handling these touch events in the viewController or shou...