cocoa-touch

Most efficient way to manage formatted strings for constantly updated UIlabels in Xcode

I have a UILabel in an interactive calculator application that is continually being refreshed with a newly formatted message as the user changes a UISlider value. My question is what is the most efficient way to manage the strings: NSString *data = [[NSString *alloc] initWithFormat:@"Value A: %0.1f, Value B: %0.1f, valueA,valueB]; myUIL...

Zooming with UITextView and Content Size

This question is similar to this one, but hopefully it will pick up some more interest due to me having tried some stuff. I am trying to do standard pinch-pan scrolling in a UITextView. My delegate implements UITextViewDelegate and implements this method - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return sel...

NSCalendar getting day difference wrong

I'm trying to use [[NSCalendar currentCalendar] ordinalityOfUnit:NSDayCalendarUnit inUnit:NSEraCalendarUnit forDate:date] on two different dates to see if they fall on the same day. However, if my time zone is different (say, somewhere in Germany), even though the dates are obviously the same, the days returned are different. If I use ...

How to scale up a PDF containing a vector-based graphic drawn by CGContextDrawPDFPage in Cocoa Touch

Hi guys, ok so here is what I want to do: Load a PDF containing a vector graphic Scale it up Draw it to a graphics context Create a UIImage from the result and present it Everything works fine, except the fact that the graphic loses quality and looks pixelized :( Here is the code where the scaling happens: // PDF loaded before CGP...

Some of my iPad pages won't rotate/resize correctly

I have an application that I submitted to the app Store. 2/5 of my pages (tabs) would not rotate/resize correctly. Thus I turned off rotation. Thus Apple rejected my application. So I went back to the drawing board. Still those two pages fail to rotate correctly. Can I reposition my text fields and such programmatically considering...

Is there an easy way with NSDateFormatter to get "Today", "Tomorrow","Friday" style dates?

Hi, I'm working on setting up NSDateFormatter to explain the date, and I'd like something short but more intuitive than 15/07/10. I think I've seen some formats that will say simply "Today" or "Tomorrow" or the day of the week for subsequent days of the same week. Is there a simple apple-approved way to get this type of date? Thanks. ...

how to get trajectory of an object1 when we swipe an object2 ?

Hi, I am writing an game app in iPad using cocos2d. And the game is in landscape mode. It have a sprite gun that shoots, and the sprite is the middle (512,10). The targets appear along the x-axis. By swiping on the sprite gun I have to generate a trajectory of the bullet according to the angle I have swiped. So, I have initial and final ...

Overriding -handlePan: in UIScrollView

Is it ok to override -handlePan: in a UIScrollView subclass? i.e. my app won't get rejected from the app store? Thanks for sharing your views. Edit: what about calling -handlePan: in another method of my subclass? ...

Iphone Orientation Issues

I have an application with the a sructure as follows UITabBarController (3 tabs) UINavigationController (in each of the tabs) UIViewController (in each of the Navigation controllers) In it I want some of the UIviewControllers to be able to switch to both landscape and potrait modes for example In Tab 2 I have a Picture Gallery...

Problem with non-transparented buttons on a transparent scrollview

Hi all. I have created a scrollview, and some button are placed on this scrollview. And scrollview is transparent with alpha = 0.5. The fact that my buttons are also transparent despite they are set to alpha of 1 and their opacity is set to YES. And I khow that I added any subview to any superView view then the properties of superview sh...

What is the difference between Cocoa Touch and Objective C

The two terms seems to be used inter changeably. Is my understanding correct that Cocoa Touch refers to the framework that handles touch whereas Objective-C is just the syntax and language used to interact with this framework? Much like WPF and C#? ...

Cocoa Touch - Checking if an int is null or un-defined?

How can I check if an int has been assigned a value? Or is still un defined? Thanks ...

Looping UIScrollView with user interaction

Hi all, I have a looping scrollView but I want the user to be able to speed up the scrolling by interacting with the scrollView (ie scrolling with their finger) if they choose. Do I have to do extra work to acheive this as at the moment the animated scrolling takes priority over the users interaction and slows the scroll down dramatical...

Releasing connection in connectionDidFinishLoading cause bad instruction

According to URL Loading System Programming Guide NSConnection sample code I can release connection in connectionDidFailWithError and connectionDidFinishLoading. However, releasing connection in connectionDidFinishLoading causing objc[19685]: FREED(id): message releaseDelegate sent to freed object=0x3b41630 Program received signal: ...

iPhone, CGPDFDocument - PDF links

Hello! I'm trying to write a simple PDF viewer using CGPDFDocument, based on QuartzDemo. There is common rendering: -(void)drawInContext:(CGContextRef)context { // PDF page drawing expects a Lower-Left coordinate system, // so we flip the coordinate system before we start drawing. CGContextTranslateCTM(context, 0.0, self...

Declare Block with return value but no args?

There is no practical reason for this, its just something I was looking at today. Does anyone know if there is a way to create a Block that does not take any arguments. In the example below Block_001 would return 101, does anyone know what I am missing? int (^Block_001) = ^{ return 101; }; If I add a int argument then the block compil...

Executing Blocks From NSArray?

Hi, I was just thinking, as you can treat Blocks like objects if I create two of them and then add them to an NSArray is there a way to execute them from the array? int (^Block_001)(void) = ^{ return 101; }; int (^Block_002)(void) = ^{ return 202; }; NSArray *array = [NSArray arrayWithObjects:Block_001, Block_002, nil]; EDIT: Update f...

NSObject doesNotRecogniseSelector crashes program

Hi, I am learning how to develop iPhone applications and I ran into an interesting problem. In my view controller class, I have a an int variable that I @synthesize and overload the setter (though) this is not needed. When I run the application, I get this trace back: * Call stack at first throw: ( 0 CoreFoundation ...

Instruments - leaks in iPad app

Running Instruments on my iPad app found 2 leaks, except I cannot understand where they are coming from. The first one is in this method in my app delegate: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [window addSubview:self.viewController.view]; // <--- it leak...

Cocoa Touch - Web View

I need help with my WebView...I put this code in my viewDidLoad and it just crashes. Any advice? [[gamerScoreWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]]; ...