EzDevInfo.com

iphone interview questions

Top iphone frequently asked interview questions

The simplest way to resize an UIImage?

In my iPhone app, I take a picture with the camera, then I want to resize it to 290*390 pixels. I was using this method to resize the image :

UIImage *newImage = [image _imageScaledToSize:CGSizeMake(290, 390)
                         interpolationQuality:1];    

It works perfectly, but it's an undocumented function, so I can't use it anymore with iPhone OS4.

So... what is the simplest way to resize an UIImage ?


Source: (StackOverflow)

Determine device (iPhone, iPod Touch) with iPhone SDK

Is there a way to determine the device running an application. I want to distinguish between iPhone and iPod Touch, if possible.


Source: (StackOverflow)

Advertisements

How to hide 'Back' button on navigation bar on iPhone?

I added a navigation control to switch between views in my app. But some of the views shouldn't have 'Back' (the previous title) button. Any ideas about how to hide the back button?


Source: (StackOverflow)

XCode 'Build and Archive' menu item disabled

I have been using the new 'Build and Archive' feature of the latest XCode 3.2.3. I like it.

Now I noticed that it is always disabled for some reason. I can't seem to figure out what I changed to cause this.

Does anyone have any ideas?


Source: (StackOverflow)

library not found for -lPods

I got an error when archiving a project. This is my environment.

  • Mac OS Lion
  • Xcode 4.3.1
  • iOS SDK 5.1

The project deployment target is:

IPHONEOS_DEPLOYMENT_TARGET 3.2

The error shows:

ld: library not found for -lPods
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I guess Pods is CocoaPods that I used to manage XCode project dependencies. https://github.com/CocoaPods/CocoaPods

This is my Podfile

platform :ios  
dependency 'libPusher', '1.1'

I am not sure what the error means?


Source: (StackOverflow)

How to print Boolean flag in NSLog?

Is there a way to print value of Boolean flag in NSLog?


Source: (StackOverflow)

iphone, dismiss keyboard when touching outside of UITextField

I'm wondering how to make the keyboard disappear when the user touches outside of the UITextField?


Source: (StackOverflow)

Turn off iPhone/Safari input element rounding

My website renders well on the iPhone/Safari browser, with one exception: My text input fields have a weird rounded style which doesn't look good at all with the rest of my website.

Is there a way to instruct Safari (via CSS or metadata) not to round the input fields and render them rectangular as intended?


Source: (StackOverflow)

Where are iOS 5 simulator screenshots stored?

I have saved some screenshots in the iPhone Simulator running iOS 5, but I can't find them.

I had this problem before, and it took me frickin' ages to find them in the file system. Is this so simple that I am just a dullard, or does no-one use this feature or what?

I know I can get the screenshots off my real phone, but I don't want retina screenshots - I want normal screenshots.


Source: (StackOverflow)

How to detect iPhone 5 (widescreen devices)?

I've just upgraded to XCode 4.5 GM and found out that you can now apply the '4" Retina' size to your view controller in the storyboard.

Now if I want to create an application that runs on both iPhone 4 and 5, of course I have to build every window twice, but I also have to detect whether the user has an iPhone with 3.5" or 4" screen and then apply the view.

How should I do that?


Source: (StackOverflow)

Set padding for UITextField with UITextBorderStyleNone

I wanted to use a custom background for my UITextFields. This works fine except for the fact that I have to use UITextBorderStyleNone to make it look pretty. This forces the text to stick to the left without any padding.

Can I set a padding manually so that it looks similar to UITextBorderStyleRoundedRect except for using my custom background image?


Source: (StackOverflow)

How to develop or migrate apps for iPhone 5 screen resolution?

The new iPhone 5 display has a new aspect ratio and a new resolution (640 x 1136 pixels).

What is required to develop new or transition already existing applications to the new screen size?

What should we keep in mind to make applications "universal" for both the older displays and the new widescreen aspect ratio?


Source: (StackOverflow)

How do I draw a shadow under a UIView?

I'm trying to draw a shadow under the bottom edge of a UIView in Cocoa Touch. I understand that I should use CGContextSetShadow() to draw the shadow, but the Quartz 2D programming guide is a little vague:

  1. Save the graphics state.
  2. Call the function CGContextSetShadow, passing the appropriate values.
  3. Perform all the drawing to which you want to apply shadows.
  4. Restore the graphics state

I've tried the following in a UIView subclass:

- (void)drawRect:(CGRect)rect {
    CGContextRef currentContext = UIGraphicsGetCurrentContext();
    CGContextSaveGState(currentContext);
    CGContextSetShadow(currentContext, CGSizeMake(-15, 20), 5);
    CGContextRestoreGState(currentContext);
    [super drawRect: rect];
}

..but this doesn't work for me and I'm a bit stuck about (a) where to go next and (b) if there's anything I need to do to my UIView to make this work?


Source: (StackOverflow)

iPhone development on Windows [duplicate]

Possible Duplicate:
How can I develop for iPhone using a Windows development machine?

Is there a way to develop iPhone (iOS) applications on Windows? I really don't want to get yet another machine.

There is a project on http://code.google.com/p/winchain/wiki/HowToUse that seemed to work with iPhone 1.0, but had limited success with iPhone 2.0, plus it requires all the Cygwin insanity.

Is there anything else, or do I have to buy a Mac?


Source: (StackOverflow)

Build fat static library (device + simulator) using Xcode and SDK 4+

EDIT: to the mod who wanted to re-write my question using inferior English, and to make it less clear: go away and write your own question. Leave mine alone - thanks!

It appears that we can - theoretically - build a single static library that includes both simulator and iPhone and iPad.

However, Apple has no documentation on this that I can find, and Xcode's default templates are NOT configured to do this.

I'm looking for a simple, portable, re-usable technique that can be done inside Xcode.

Some history:

  • In 2008, we used to be able to make single static-libs that included both sim and device. Apple disabled that.
  • Throughout 2009, we made pairs of static libs - one for sim, one for device. Apple has now disabled that too.

References:

  1. This is a great idea, it's an excellent approach, but it doesn't work: http://www.drobnik.com/touch/2010/04/universal-static-libraries/

    • There's some bugs in his script that means it only works on his machine - he should be using BUILT_PRODUCTS_DIR and/or BUILD_DIR instead of "guesstimating" them)
    • Apple's latest Xcode prevents you from doing what he's done - it simply will not work, due to the (Documented) change in how Xcode processes targets)
  2. Another SO questioner asked how to do it WITHOUT xcode, and with responses that focussed on the arm6 vs arm7 part - but ignored the i386 part: How do i compile a static library (fat) for armv6, armv7 and i386

    • Since Apple's latest changes, the Simulator part isn't the same as the arm6/arm7 difference any more - it's a different problem, see above)

Source: (StackOverflow)