EzDevInfo.com

ios7 interview questions

Top ios7 frequently asked interview questions

Xcode 5 without Storyboard and ARC

i have downloaded new xcode-5 and just started using it.

We can create application directly including storyboard and ARC , it is not asking for option like earlier versions.

So, my question is how can we use xcode5 without ARC and storyboard. we have to manually remove storyboard file ? or is there any other option.

Thanks in advance.


Source: (StackOverflow)

preferredStatusBarStyle isn't called

I followed this thread to override -preferredStatusBarStyle, but it isn't called. Are there any options that I can change to enable it? (I'm using XIBs in my project.)


Source: (StackOverflow)

Advertisements

How to change Status Bar text color in iOS 7

My application has a dark background, but in iOS 7 the status bar became transparent. So I can't see anything there, only the green battery indicator in the corner. How can I change the status bar text color to white like it is on the home screen?


Source: (StackOverflow)

@import vs #import - iOS 7

I am playing around with some of the new iOS 7 features and working with some of the Image Effects as discussed in the WWDC video "Implementing Engaging UI on iOS". For producing a blur effect within the source code for the session, UIImage was extended via a category which imports UIKit like so:

@import UIKit;

I think I saw something about this in another session video but I'm having trouble finding it. I'm looking for any background information on when to use this. Can it only be used with Apple frameworks? Are the benefits of using this complier directive enough that I should go back and update old code?


Source: (StackOverflow)

Replacement for deprecated sizeWithFont: in iOS 7?

In iOS 7, sizeWithFont: is now deprecated. How do I now pass in the UIFont object into the replacement method sizeWithAttributes:?


Source: (StackOverflow)

invalid context 0x0 under iOS 7.0 and system degradation

I've read as many search results I could find on this dreaded problem, unfortunatelly, each one seems to focus on a specific function call.

My problem is that I get the same error from multiple functions, which I am guessing are being called back from functions that I use.

To make matters worse, the actual code is within a custom private framework which is being imported in another project, and as such, debugging isn't as simple?

Can anyone point me to the right direction? I have a feeling I'm calling certain methods wrongly or with bad context, but the output from xcode is not very helpful at this point.

: CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

: CGContextSetStrokeColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

CGContextSaveGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

: CGContextSetFlatness: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

: CGContextAddPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

: CGContextDrawPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

: CGContextRestoreGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

: CGContextGetBlendMode: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

Those errors may occur when a custom view is presented, or one of its inherited classes. At which point they spawn multiple times, until the keyboard won't provide any input. Touch events are still registered, but system slows down, and eventually may lead to unallocated object errors.

EDIT #1: I do have access to the framework being imported, but I do not see anything weird in the classes which causing the issue.

EDIT #2: I just received an email that iOS 7.1 has been released for developers. I'm curious to see if this goes away, or become worse, or can be solved.


Source: (StackOverflow)

Why is there extra padding at the top of my UITableView with style UITableViewStyleGrouped in iOS7

Starting in iOS7, there is additional space at the top of my UITableView's which have a style UITableViewStyleGrouped.

Here is an example:

enter image description here

The tableview starts at the first arrow, there is 35 pixels of unexplained padding, then the green header is a UIView returned by viewForHeaderInSection (where the section is 0).

Can anyone explain where this 35 pixel amount is coming from and how I can get rid of it without switching to UITableViewStylePlain?


Source: (StackOverflow)

Cannot hide status bar in iOS7

I just upgraded my iPhone 5 iOS 7 to four beta version. Now when I run my app from Xcode 5 on this iPhone, status bar doesn’t hide, even though it should.

Not Working:

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];

Not Working:

[UIApplication sharedApplication].statusBarHidden = YES;

Can't login to Apple Developer Forums


Source: (StackOverflow)

UITableViewCell show white background and cannot be modified on iOS7

I've implemented a custom table view cell class that inherit from UITableViewCell. The tableview contains a background image, so I want cell's background to be transparent. It looks great before iOS7.

However, in iOS7, the cell is always shown with a white background.


Even for Xcode7, 2015, there is a bug in storyboard: you have to set the background color of a cell in code.


Source: (StackOverflow)

iOS 7 navigation bar custom back button without title

How can I customize the navigation back button in iOS 7 without title? (i.e. with the arrow only)

self.navigationItem.leftBarButtonItem = self.editButtonItem;

I'm just wondering if they have any self.backButtonItem;

OR

something like this?

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
                   initWithBarButtonSystemItem:UIBarButtonSystemItemBACK 
                   target:self action:@selector(back)];

Source: (StackOverflow)

How to change Navigation Bar color in iOS 7?

How do I change the Navigation Bar color in iOS 7?

Basically I want to achieve something like the Twitter Nav Bar (updated Twitter for iOS7 that is). I embedded-in a nav bar atop a view controller. All I want is to change the nav bar color to light blue along with the utility bar at the top. I can't seem to find an option in my storyboard.


Source: (StackOverflow)

Explaining difference between automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars, edgesForExtendedLayout in iOS7

I have been reading a lot about iOS7 UI transition.

I am not able to get what these three properties automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars, edgesForExtendedLayout??

For example I am trying to make my view controllers start below the status bar but I am not able to achieve it.


Source: (StackOverflow)

Will iOS launch my app into the background if it was force-quit by the user?

I am triggering a background fetch by using the content-available flag on a push notification. I have the fetch and remote-notification UIBackgroundModes enabled.

Here is the implementation I am using in my AppDelegate.m:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
    NSLog(@"Remote Notification Recieved");
    UILocalNotification *notification = [[UILocalNotification alloc] init];
    notification.alertBody =  @"Looks like i got a notification - fetch thingy";
    [application presentLocalNotificationNow:notification];
    completionHandler(UIBackgroundFetchResultNewData);

}

When the app is running in the background, it works fine. (The notification is received and the app triggered the "looks like i got a notification" local notification, as the code above should do).

However, when the app is not running and a push notification is received with the content-available flag, the app is not launched and the didRecieveRemoteNotification delegate method is never called.

The WWDC Video Whats New With Multitasking (#204 from WWDC 2013) shows this: enter image description here

It says that the application is "launched into background" when a push notification is received with the content-available flag.

Why is my app not launching into the background?

So the real question is:

Will iOS perform background tasks after the user has force-quit the app?


Source: (StackOverflow)

UIImagePickerController breaks status bar appearance

In my .plist file, I have "View controller-based status bar appearance" set to NO. But after UIImagePickerController, my app behaves as if the option is set to YES.

In my app, I present a VC that presents a UIImagePickerController.

The problem happens like this:

  • After photo picker is presented, when a photo library is picked, the color of the status bar text changes.
  • Then once, UIImagePickerController is dismissed, status bar spacing changes for the rest of my app and all the navigation bar for other controllers displays under the status bar.

Is there a way to solve this without managing status bar in my view controllers?


Source: (StackOverflow)

Autoresizing issue of UICollectionViewCell contentView's frame in Storyboard prototype cell (Xcode 6, iOS 8 SDK) happens when running on iOS 7 only

NOTE: Got another serious bug with UITableViewCell in Storyboard. FYI if you also Static Cell on Xcode 6: Static UITableViewCell subviews are resized incorrectly (was off the screen, over the right edge) on Xcode 6.1.1, iOS 8.1 SDK

Update 2: Paste this code at the beginning of your cellForItem and things should be okay:

/** Xcode 6 on iOS 7 hot fix **/
cell.contentView.frame = cell.bounds;
cell.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
/** End of Xcode 6 on iOS 7 hot fix **/

Update 1: This problem still exists in the official Xcode 6.0.1 ! The best work around is like what KoCMoHaBTa suggested below by setting the frame in cellForItem of the cell (You have to subclass your cell though). It turned out that this is a incompatibility between iOS 8 SDK and iOS 7 (check ecotax's answer below quoted from Apple).

Original: I'm using Xcode 6 Beta 3, iOS 8 SDK. Build Target iOS 7.0 using Swift. Please refer to my problem step by step with screenshots below.

I have a UICollectionView in Storyboard. 1 Prototype UICollectionViewCell which contains 1 label in the centre (no autoresizing rule). Purple background was to mark a contentView that is generated in runtime by the Cell I guess. That view will be resized properly base on my UICollectionViewLayoutDelegate eventually, but not on iOS 7. Notice that I'm using Xcode 6 and the problem only happens on iOS 7.

When I build the app on iOS 8. Everything is okay.

Note: Purple is the contentView, Blue is my UIButton with rounded corner.

http://i.stack.imgur.com/uDNDY.png

However, on iOS 7, all the subViews inside the Cell suddenly shrink to the frame of (0,0,50,50) and never conforms to my Autoresizing rule anymore.

http://i.stack.imgur.com/lOZH9.png

I assume this is a bug in iOS 8 SDK or Swift or maybe Xcode? I'm stuck with this for 2 days without any hope of resolving it. Your help is appreciated.

Thanks a lot guys! Kien.


Source: (StackOverflow)