Swift iOS interview questions and answers – Part 2 – Auto layout & UIKit

Uplift iOS Interview

The Guide is for YOU if
  • You are preparing for an iOS interview and want to improve your skills and knowledge and looking to level up your interview game and land your dream job.
  • You want to gain confidence and ease during iOS interviews by learning expert tips and curated strategies.
  • You want access to a comprehensive list of iOS interview QA to practice and prepare.

Part 2 consists Swift iOS interview questions and answers of UI – Auto layout & UIKit. It will cover UI related topics such as frame, bound, autolayout constraints, xib, storyborad, safe area etc.

What is bounding box?

The bounding box is the smallest rectangle completely enclosing all points in the path, including control points for Bézier and quadratic curves.

What is CGpath?

An immutable graphics path: a mathematical description of shapes or lines to be drawn in a graphics context.

Do your need weak or unowned for UIView animation?

weak or unowned self is used to prevent retain cycles. After UIView animation runs, the memory is deallocated even if it is strongly referenced. Weak and unowned is not needed for animation code block. You don’t need to use [weak self] in static function UIView.animate() You need to use weak when retain cycle is possible and animations block is not retained by self. The external object reference captured by them will only be kept for certain amount of time, which means it’s definitive that it’s going to be executed at one point of time. After this, it will be released so there is no chance of reference cycle which leads to memory leak.

What is the difference between the frame and the bounds?

The frame is the rectangle which has location and size relative to the superview. On the other hand, the bounds is the rectangle which has location and size relative to its own coordinate system.

When should you use frame/bounds?

Frame relates a view’s location in its parent view. It can be used when you are making outward changes for example changing its width or finding the distance between the view and the top/bottom/left/right of its parent view.

On the other hand you can use the bounds when you are making inward changes for example draw items or arrange subviews within the view. You can also use the bounds to get the size of the view if you do any transformation on the bounds.

What is an unwind segue?

An unwind segue moves backward through one or more segues to return the user to a scene managed by an existing view controller.

What is intrinsic content size?

All views have an intrinsic content size which refers to the amount of space the view needs for its content to appear in an ideal state. For example, the intrinsic content size of a UILabel will be the size of the text it contains using whatever font you have configured it to use.

What’s the difference between a xib and a storyboard?

A xib defines a single View or View Controller screen, while a storyboard shows many view controllers and also shows the relationship between them.

What is difference between layout margins and directional layout margins ?

Layout margins property of a UIView is of type UIEdgeInsets and defines the top, left, bottom and right insets that when applied to the view’s frame define the view’s margin.

Directional layout margins that are aware of right to left (RTL) languages. This follows the pattern used when creating constraints with layout anchors.

What is Safe area ?

Safe area allows us to create constraints to keep our content from being hidden by iOS specific hardware bars.

What is content offset?

When we scroll a scrollView it modifies a property known as content offset. Using this value the scrollView can compute its new bounds and redraw any of its subviews.

What is NSLayoutAnchor ?

NSLayoutAnchor is used to write auto layout easier in code.

What is UIBezierPath?

We can define custom path by UIBezierPath to create any shape.

What is reuseIdentifier in UITableView/UICollectionView?

The reuseIdentifier indicates that cells for a UITableView (or UICollectionView) can be reused. UITableView maintains an internal cache of UITableViewCell with the appropriate identifier and allows them to be reused when dequeueForCellWithReuseIdentifier is called. As a result, this increases performance of UITableView since a new view does not have to be created for a cell.

Fellow iOS Developers, Please Keep In Mind

  • It’s important to keep in mind a few key points as you prepare for your interview. Firstly, it’s worth noting that there are over 1000 interview questions available in the interview section for you to review and prepare for. While reading the question, take the time to carefully consider your answer and think about the information that you want to convey. The answer provided here in this blog can be explained in a different way. You should also prepare your examples.
  • It’s also important to remember that these interview questions are not meant to be difficult. The interviewer is not looking to challenge you, but rather to start a conversation that will allow your abilities and interests to come to the forefront. They want to get to know you and your experience better.
  • Finally, it’s crucial to avoid simply answering questions with a “yes” or “no.” Interviewers are looking for more in-depth responses that include basic understanding, reasoning, explanation, and examples. So, make an effort to elaborate on your answers and provide specific, relevant information to support your response. This will demonstrate your thoughtfulness and show the interviewer that you are well-prepared for the interview.

Swift iOS interview questions and answers

Swift iOS interview questions and answers – Part 1

Swift iOS interview questions and answers – Part 2

Swift iOS interview questions and answers – Part 3

Swift iOS interview questions and answers – Part 4

Swift iOS interview questions and answers – Part 5

Planning to apply for iOS job? Check out this article to uplift your resume! Happy job hunting!



✍️ Written by Ishtiak Ahmed

👉 Follow me on XLinkedIn



Get Ready to Shine: Mastering the iOS Interview




Enjoying the articles? Get the inside scoop by subscribing to my newsletter.

Get access to exclusive iOS development tips, tricks, and insights when you subscribe to my newsletter. You'll also receive links to new articles, app development ideas, and an interview preparation mini book.

If you know someone who would benefit from reading this article, please share it with them.