cocoa-touch

Knowing when -viewWillAppear triggered but -viewWillDisappear hasn't

Is there a way to know that a view controller is somewhere in the view controller lifecycle between -viewWillAppear and -viewWillDisappear? I ask because I want to be damned sure that a method isn't fired when my view is either not on screen, or is about to disappear from the screen. When the view is about to disappear from the screen, ...

How can I determine UITabBarItem position?

How can I determine if a UITabBarItem has the title "Hello" and is in position 0? ...

Why I cannot overriding the ccTouchBegan method in CCSprite using cocas2d?

I am using cocos2d to develop a game. I used a TouchableSprite as follow: http://www.cocos2d-iphone.org/forum/topic/3196 So, I create a new class which is a sub class of TouchableSprite. But it have some problems.... See the code first: #import <Foundation/Foundation.h> #import "TouchableSprite.h"; @interface MySprite : TouchableSpri...

Converting an NSString to an NSInteger

if i have: NSString* number = @"2000"; Will NSInteger integerNumber = [number integerValue]; be equal to the integer representation of 2000? ...

How to coalesce KVO changes?

I have a fairly simple iPhone app that downloads a set of UITableView results into its model class, and a view controller that's set up to observe these changes using KVO. This system works well (much better than scattering update code everywhere), except that when I get results, I add them to the backing NSMutableArray one-by-one. Thi...

UITextField, becomeFirstResponder, resignFirstResponder

When a UITextField object becomes first responder the keyboard magically appears. When it resigns first responder the keyboard magically slides away. What is causing this to happen? Is there something constantly watching in the background and makes the keyboard appear/disappear when it notices a text field becoming/losing first responder...

custom UIViewController subview does not rotate but superview does, help me work out why?

Simple iPad app. App loads and displays a UITableView controlled by a subclass of UIViewController. This works and rotates perfectly. Clicking on a row in the table view causes a new subview to be created, also controlled by a UIViewController subclass. This displays fine in portrait but does not adjust to landscape and does not respon...

Contents of UIScrollView gets re-rendered when a UITableView in a UIPopoverController is scrolled

The title pretty much sums it up, but what's happening is that I have a UIPopeverController popping up and presenting a UITableView from a toolbar button. Underneath the popover I have a large UIScrollView with several PDF pages being rendered into CATiledLayers using Quartz. Whenever I try to scroll in the popover (the UITableView real...

Change the number of rows in a section depending on a variable.

In my 'Sectioned' UITableView I have two sections, the first one for Attributes like name and the second one is editable where you can add objects. Here's a picture of it: There's an attribute that the user can change (in this case Type) which would to change the number of rows in second section. To be more specific, if one property i...

Remove keyboard or place Picker View on TOP of keyboard

Anyone has any idea how one can achieve the same look as when you press on the "From:" in the Mail iphone app when you have more than one user account. I'd like to remove my keyboard, but WITHOUT animating it. Rather just disappear and instead of it have a UIPickerView appear. Thanks much! ...

Quick overview of the structure if iPhone apps

Can someone give me a quick, one-to-few paragraph(s) overview of the structure of iPhone apps. I'm working my way through a book, but I can't really understand the purpose of App Delegates, MainWindow.xib vs. individual views' nib files, actions vs. outlets, etc. I'm looking for a high-level description, because all I can find are real...

Optimize memory consumption when gradually writing to a file

Hi! I've been doing some tests, and one of my needs is to read data from different xml files and stack it together on a single file. While I've managed to accomplish this, memory consumption seems to be quite large for the task, the iphone simulator didn't even raise the memory warning, but I don't think the real iPhone would tolerate th...

Is NSURL supposed to parse invalid URLs?

I could not really find this in the documentation ... I'm writing some unit tests and one of the tests that is supposed to fail is [NSURL URLWithString: @"cow"]. Because cow is not a valid URL. However, it is happily parsed by NSURL with no errors at all. It does not return nil and it does not throw an exception. Calling [url absoluteS...

Cocoa Touch - Getting the current image of an animation?

I want to get the current image in an animation, How can I do it? //Set up bottom view UIImageView *bottomView = [[UIImageView alloc] initWithFrame:CGRectMake(30, 180, 50, 150)]; bottomView.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"redLight.png"], ...

reimplementing NSObject from scratch

When I was reading about the new 4.0.2 iOS update I wanted to know what hackers do or try doing with a buffer overflow, which after some wikipedia'ing got me interested in playing with malloc and thus creating my own "NSObject". I am not actually planning to use this in any of my applications, its only for learning and playing around wi...

Time out with Synchronous NSURLConnection

I am writing an application that uses Synchronous NSURLConnection(s) and am finding that my application hangs if the url entered is incorrect. I tried to set a time out of .5 seconds but it does not seem to take. I read somewhere that it is not possible to set a time out on a Synchronous request (and yes it is very important to the appli...

How to get the coordinate of a touch event

How do I determine where the user touched in my view? ...

UISegmentedControl customization

I have a UISegmentedControl on one of my pages. I want an editbox to appear when a segment is clicked right below the clicked segment. I would like it to be animated (slide in or something) Is this possible? What would be the best way to do this? Damn.I forgot to mention all this action is going to occur within a cell and not a simple ...

help with reading text body from a web page

Hi all ... when I use : NSString *myText = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.innerText"]; NSLog(@"my text -> %@",myText); I get all the JavaScript for the webView but what i want is to save the body text only from the web page so can any body help me with some codes or any ideas thanks ...

How to remove (pop) a view from OTHER view?

Hi, I have 2 views. One is the 'viewheader' and the other is the 'viewContent' (added as subview). 'viewContent' contains a TableView (based on UINavigationController) and the TableView can drill down to a DetailView (UIViewController). (see Image below) My Question is: How can I remove (pop) the DetailView, with a UIButton FROM the '...