Outlets in Xcode 6 (Universal Application)

Asked

Viewed 140 times

2

I have a problem/doubts. Until today due to some needs I developed only for iPhone or iPad separately, but today I’m starting in the development of universal application, iPhone and iPad.

I’m using Xcode 6 and developing directly for iOS 8. I was able to adapt the screens for both devices, it was cool except for the fact that: when I built the screens using the storyboard, added a UITabBar and I referenced it as Outlet on my controller. When I adapted to the iPad screen, I had to add another UITabBar (I actually had to add all the components because it was empty). When trying to reference how Outlet in class, I could not, because she "overwrites", losing my outlet of iPhone screen and vice versa.

My doubts are as follows:

  • What’s the best way to do that?
  • Every time I create a screen for iPhone and adapt the screen for iPad, I have to add all components again?
  • In case of overwriting, what is the correct alternative to do this?
  • Will I need to have two controllers? One for iPad and one for iPhone?

IMPORTANT: To know how I create the layout and codes: I have not written any code, I am still in the stage of creating the screens and create the layout in the same way as in this video: https://www.youtube.com/watch?v=p5wD8dvSDbM

  • If you designed your layout for iPhone and iPad, it’s really not possible to refer to it IBOutlet, unless you draw the same layout with Any|Any and using the constraints correctly. The UITabBar for example, it’s one of the things I can’t imagine because you couldn’t do it universally without needing 2 IBOutlet.

  • @Paulorodrigues the problem really was in Any|Any. After seeing your comment I noticed that the problem was where I inserted the components on the iPhone screen and not on the Any|Any screen, thus not being able to duplicate to the iPad. Could you please put as an answer?

1 answer

1


In fact it is not possible to make reference to the same IBOutlet if you have different layouts for iPhone and iPad, for example.

You drawing a single layout in mode Wany|Hany, note that in the preview and even in the video you indicated, it is possible to use the same component and the key to this is the use of constaints correctly.

inserir a descrição da imagem aqui

As in your case, the UITabBar you achieve the same result universally and with the same IBOutlet applying the constraints width, central alignment, attach to footer and etc.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.