objective-c

How to set the title of UIToolBar?

How can I set the title of UIToolBar such that it looks the same as the title in UINavigationBar? I tried to use a button with plain style, it looks ok, but it will be highlighted when I click on it... Is there any better way to set the title in the detail view of split view? ...

how to crop an image using rectangale overlay and touch on iphone

Hey Everyone, I am looking for a good tutorial or sample code, that would show how to crop an image taking from iphone camera something in lines of http://img192.imageshack.us/img192/8930/customcropbox.jpg but you would control the corners with your fingers any tip would be greatly appericated, as i am new to iphone dev. Thank...

Objective C: Include class and call method

I have built a class which has a few methods in it, once of which returns an array, lets call this class A. I have a second class, class B, which I would like to use to call the method from class A. But, now how do I call that method from class A and store what is returned in a var in class B? Do I have to initiate the class? I have ...

Display different iphone views depending on logged in status

I want to display a login view to my users if they are not logged in and the main view if they are. In my header file I define a variable to hold the logged in status #define loggedIn 0 I figure I should then reference this in the initWithNibName method and then decide which nib to load. Is the right way of doing it? If so can some...

Why can't I initialize a class through a setter?

If I have a custom class called Tires: #import <Foundation/Foundation.h> @interface Tires : NSObject { @private NSString *brand; int size; } @property (nonatomic,copy) NSString *brand; @property int size; - (id)init; - (void)dealloc; @end ============================================= #import "Tires.h" @implementation Tir...

Tab Bar and Nav Controller: Where did I go wrong in my Interface Builder wiring?

I've been working on an iPhone application in XCode and Interface Builder of the Tab Bar project type. After getting a table view of topics (business sectors) working fine I realized that I would need to add a Navigation Control to allow the user to drill into a subtopics (subsectors) table. As a green Objective-C developer, that was co...

Drawing using accelerometer

Hi.. I'm trying to do a project that is basically a remake of the already posted apps on the AppStore namely movosity and air paint. Can anybody give me an idea as to what approach should I take? Thanks in advance ...

Changing position of selector programmatically in Pickerview when it is initially loaded.

How can we change the position of the selector in the Pickerview when it is loaded. For example, I want to make row 3 initially selected when it is loaded. Anyone please help. ...

How do you load data into a Table View when there's both a Tab Bar and a Nav Bar?

I think I'm way overthinking the issue of having a Tab Bar project type and adding Nav Bar controls. I've followed some basic directions and have a demo app running fine with two tabs, each with a Table View and nav bars. But how do I load data into them? I know I need to hook up delegate and dataSource, but where? ...

Can get coordinates from iPhone simulator, but can't get coordinates from iPhone device

Hi everyone, I've run into something of a mysterious bug (to me). I have some code to pick out the user's current location on the iPhone SDK. It works fine on the iPhone simulator, but when I try to run it on the actual device, I get a weird error. Here is the code (I am using ASIFormDataRequest to create a POST request): ASIFormData...

AVAudioPlayer not unloading cached memory after each new allocation

I am seeing in Instruments that when I play a sound via the standard "AddMusic" example method that Apple provides, it allocates 32kb of memory via the prepareToPlay call (which references the AudioToolBox framework's Cache_DataSource::ReadBytes function) each time a new player is allocated (i.e. each time a different sound is played). ...

Is it possible to distribute an app that has files in NSDocumentDirectory?

I know how to put files into a bundle. These are read-only; the user cannot modify them at runtime. I know how to write files NSDocumentDirectory at runtime. These are read-write. I know I can copy files from a bundle into NSDocumentDirectory the first time my app starts up. I am wondering if there is a way to package writeable files ...

Objective-C scanf spaces issue

I am learning objective-C and for the life of me can't figure out why this is happening. When the user inputs when the code is: scanf("%c %lf", &operator, &number); For some reason it messes with this code: doQuit = 0; [deskCalc setAccumulator: 0]; while (doQuit == 0) { NSLog(@"Please input an operation and then ...

Consecutive 'if' statements

EDITED FOR TYPO - How can I check one thing AND THEN another, if the first is true? For example, say I have a shopping basket object, and I only want to do something if the basket has been created AND it isn't empty. I've tried: if ((basket) && ([basket numberOfItems] >0))... But the second condition is evaluated even if the first...

When are dynamically loaded NIBs assigned frames and bounds data?

In one of my UIViewControllers, I am calling initWithNibName:bundle: for several other UIViewControllers. I am grabbing the view property in each of those dynamically created controllers and placing them, one after the other, in my parent view. For instance, the y offset of viewControllerB should be equal to the height of viewControllerA...

Removing object from NSMutableArray

Just a small query... I stumbled across the following shortcut in setting up a for loop (shortcut compared to the textbook examples I have been using): for (Item *i in items){ ... } As opposed to the longer format: for (NSInteger i = 0; i < [items count]; i++){ ... } //think that's right If I'm using the shorter version, is there ...

How to detect swiping left / right on the iPhone?

Is there any easy way to detect these kinds of gestures for iPhone? I can use touchesBegan, touchesMoved, touchesEnded. But how can I implement the gestures? thz u. ...

How do I create a preferences window in Objective-C?

I would like to create a preferences window like in the standard Mac OS X apps (Safari etc.). I have found resources like DBPrefsWindowController from back in 2008 that matches the Apple HIG. Just wondering if there is a new way to accomplish this? I can't locate any standard windows in Interface Builder so I assume Apple doesn't pr...

Adding # & search sign to TableIndex in UITableView

In iPhone native Phone book - there is a search character at the top & # character at the bottom. I want to add both of that character in my table Index. Currently I have implemented following code. atoz=[[NSMutableArray alloc] init]; for(int i=0;i<26;i++){ [atoz addObject:[NSString stringWithFormat:@"%c",i+65]]; } ...

How to let the pageController control the UIImageView?

I want a UIImageView swipe left, the UIImageView will change the image, at this time, the pageController +1, if swipe right, the pageContoller -1, and display the previous image... ...How can I implement it? Any simple code? thz u. ...