cocoa-touch

Iphone - Class property causes crash

Hi, So I'm still very new to this whole objective C think and I ran into a problem I'm not sure the root cause for. My h file looks basically like this : @interface DrinkDetailViewController : UIViewController<UITextFieldDelegate> { UITextField* nameTextField; UITextField* activeView; } @property (nonatomic,retain) IBOutlet UI...

Cache a webpage on the iPhone with UIWebView

How can I load a web page when internet is available and cache it for offline use and it updates to the latest version when internet becomes available again? ...

viewWillAppear question

-(void)viewWillAppear:(BOOL)animated{ //something here [super viewWillAppear]; } my question is is this line [super viewWillAppear]; always required? if not when and why do you use it? ...

UIDatePicker select Month and Year

I need a UIDatePicker for selecting Month and Year only. I checked the class reference documents. Looks like UIDatePicker is a UIView. I imagined UIPickerView may be a sub view and I can hide the component if I can grab it. But no. That was not possible. Do I have to create my own custom picker then? Any ideas? ...

could not locate an NSManagedObjectModel for entity name

Hi, This is the code for toggleAddProject method, the Core Data code is almost the same as found in Apple's CoreDataBooks sample, however when I click the add button the app crashes with entityForName: could not locate an NSManagedObjectModel for entity name 'Project' on the line starting with newProjectController.project -(IBAction)t...

Problem zooming into UIImageView

I am following Apple's ScrollSuite example, however pinch to zoom is not working. I am not sure whats wrong: // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; // set up main scroll view imageScrollView = [[UIScrollView alloc] initWithFram...

Using an object other than File's Owner for IBOutlets and IBActions

I have a currently working program that has IBOutlet and IBAction connections from the interface to File's Owner. I made a new class, and added that to the document window in Interface Builder. Then I moved everything from the File Owner class files to the new class files. I removed the old connections and reconnected everything to the n...

How to autorotate UIScrollView and UIImagewView programatically?

I have a UIScrollView and a UIImageView which I have created programatically without interface builder. How can I make sure both auto-rotate in horizontal orientation? ...

Objective-c regex to check phone number

How to validate a phone number (NSString *) in objective-c? Rules: minimum 7 digits maximum 10 digits the first digit must be 2, 3, 5, 6, 8 or 9 Thanks ...

Adding Sections to a UITableView.

How would I have a button that would add a Section to a UITableView? I know how to do it without adding sections and just having a list but how would you allow the user to add section as well as cells/rows. ...

How do I hide the textfield cursor on the iPhone when keyboard is active.

we are trying this for password settings,so that cursor should not be visible to user. ...

Is this a sensible app design?

Hi. After much reading and many tutorials I'm now attempting to write my first iPhone app, but already starting to run into complications so want to go back to basics and ask whether I've got the fundamental UI design correct: MainWindow.xib has a TabBarController. The TabBarController contains 3 NavigationControllers, each containing ...

Showing UIBezierPath on view

In one of my methods i have this code: -(void)myMethod { UIBezierPath *circle = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(75, 100, 200, 200)]; } How do i get it to show on the view? I tried addSubview but it gave me an incompatible type error because its expecting a UIView. I'm sure this must ...

Cocoa Touch - Text Boxes Question

I have a chalk board image and I want it to be like it your writing on the chalk board so the textbox would have to invisible but still functioning.... Any idea how I could do that? ...

How can I break the "navigation stack" in a Cocoa Touch App ?

Hi everybody, I'm currently trying to create a navigation based application, pushing views to change the screen content. I'm trying to set up a button which can allow me to "restart" from the first screen, but I can't figure out a way to do that. If I "push" the first view, there will be a "back" button, and I'll just have another piec...

UITableView giving strange results

Hi all, Im sure this is going to be one of those things where someone points out something really obvious that Im doing but I cant for the life of me find the problem. Basically I have an array of strings and I am loading the text from the array into my uitableviewcells as and when it is needed. The problem comes when I begin to scroll ...

Convert NSDate to NSString

I have the following: NSDateFormatter* df = [[NSDateFormatter alloc]init]; [df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"]; NSDate* date = [df dateFromString:[sDate stringByReplacingOccurrencesOfString:@"Z" withString:@"-0000"]]; [df release]; I would like the output string to be "9/20/10" How can I do this? ...

How can I append text to the bottom of my MFMailComposeViewController?

I would like to add the text "Sent from " to the bottom of the message if([MFMailComposeViewController canSendMail]){ MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init]; controller.mailComposeDelegate = self; [controller setSubject:[NSString stringWithFormat:@"A message from: %@",se...

How can I present a UIView from the bottom of the screen like a UIActionSheet?

I'd like a UIView to slide up from the bottom of the screen (and stay mid-screen) like a UIActionSheet. How can I accomplish this? UPDATE: I am using the following code: TestView* test = [[TestView alloc] initWithNibName:@"TestView" bundle:nil]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.4]; [UIView setAni...

getRandomColor but avoid dark colors: Help my algorithm

I am trying to get a random color. I have done it using brute force but this method seems overly laborious (though the distribution is pretty even): - (UIColor *) getRandomColor { // GOAL: reject colors that are too dark float total = 3; float one = arc4random() % 256 / 256.0; total -= one; float two = arc4random() % 256 / 256.0; ...