xcode 8 auto layout uiimageview problems - swift

I have a Android background and now try to code for iOS.
I use Swift as the language and it works really good so far. Now I am getting some troubles to get my layout to work on different screen resolutions that means different iPhones.
I am using storyboards for my ViewController and for now everything worked well except getting UIImageViews to look the same on each iPhone.
I tried now for 2 whole days with dozens of different approaches to get my layout work, but without any success. If I place a single UIImageView on my layout I am able to set the constraints so that it looks the same on each iPhone. Once I place a UIImageView on top of my first UIImageView it destroys everything. I won´t tell you here what I already tried, because it was a lot and nothing worked for me.
I need really some hint or just someone who could just try it on his Storyboard and tell me how he achieved it to get it work. I am using Xcode 8.2.1.
This is how it should look like (iPhone 7):
This is how it looks on a iPhone 4s --> wrong! Proportions are not the same!

It's need more params and maybe UIStackViews.
https://github.com/OMGHaveFun/exampleAutolayout

Related

Is it possible to fix an iPhone app for iOS6+7 and 3.5 + 4 inch displays without editing code?

At this time I'm trying to edit an app of mine to support iOS6+7 aswell as 3.5+4 inch displays.
However I'm trying to do this without changing the code. And it works fine...for one of my requirements.
First I tried fix the 3.5/4 inch display issue with autolayout/contraints. It worked well but either it looked good with iOS6 or iOS7. And I didn't find a way to fix the iOS6/iOS7 diffrence without adjusting tons of code.
Then I resetted my contraints, disabled autolayout and fixed the iOS6/7 issue via offsets (iOS6/7 Deltas). Worked fine too for resolving the other requirement.
Since you can't use offsets AND autolayout at the same time I'm wondering if it's not possible to fix both problems without either checking iOS version or display size in my code?
I didn't provide code or screenshots because it's a more general question and I'm trying to solve this issue without touching my code. However what I can say is that I'm using .xib files to create the views not knowing if that's a problem too...
Thanks in advance,
blaluma
if your using storyboard with autosizing you can achieve that one

Problems with presenting views in Xcode

I hope you can help me with my actual problems with designing an iPhone-App in the latest xCode version.
Here´s what I find a bit strange:
I designed a new project with a Storyboard and a Navigation Controller. Then I placed Objects like UILabels, ImageViews and so on. No when I run the Project in the simulator (as well on the iPhone) I noticed the following: When the App loads all the in the View placed objects fall down from the top to take their defined place. It takes maybe the quarter of a second, but its clearly to see. It also happens on all other views initiated from the root view controller
So, what do I have to change that everything is at it´s fixed place without to fall down from the top at the start of the app?
I hope I described it good enough. Actually I have no idea what´s going on there. I hope you can help me to fix this "problem". I´ve written some small Apps before, but I´ve never noticed a behavior like this.
Got the solution: I´ve had to remove the animations on the main view... now it works proper! :-)

iPhone 5 Image Issuses

I have an app that I am making but the background image I am using wont work on my iPhone 5. Everything works on it when I load it on my iPhone 4. It was size the -568h#2x.png right it looks massive or it will load the #2x.png and give it a tile look. Any one know would could be wrong. I've tried making a UIImage in IB and programmatically. Neither have been successful. I've even tried if else methods to loads different pngs based on the screen height. I'm at a point where I could just quit. Any direction or guidance. I have all my code but didn't know what would be the best pice to post. Thanks
Sounds like you might need to make two separate storyboards/xibs, one for an iPhone 5 and another for the iPhone 4S/4/3GS, etc. Here's a link that will tell you how to do it.

Convert Separate TableViewController and ViewController into UISplitView

I currently have an iOS application that was originally developer for the iPhone; it was then decided that it was going to be required for the iPad as well. However, there are not many changes to cater for this (only things such as layout, text size and a few others) - the app is just a bigger version for iPad in reality.
One of the things my app makes use of is a UITableView (with a custom UITableCellView). Each one of these then moves onto a UIView. In order to make it a bit more unique to the iPad, I would like to implement a UISplitView to combine these two, to make better use of the larger screen!
This application was handed to me from a previous developer. A large part (95%) of the UI was coded (and not done in Interface Builder). While I am picking up objective-c, there are still some things which throw me. Therefore, my question to you guys is: would this require a huge change in code if I was to combine my UITableView and UIView into a UISplitView? From what I have seen from playing around with the UISplitView, it doesn't seem so. However, because of all the rest being coded, I think the UISplitView will have to be, is that right? Or can I dump in an xib and string up the coded UITableView and UIView?
Final question, is there a tutorial anyone knows about where they have coded a UISplitView? All of them appear to be using Interface Builder.
I hope that is not too much information!

Tricky performance problem about UIButton's in UITableViewCell (iPhone)

I'm going to implement a view similar to the original photo app in iOS.
I created a customized UITableViewCell which has 4 UIButton in it. And it updates the button's image when the image array of the cell changed.
I worked hard to get the performance really satisfying. However, I found a tricky lag problem about it.
When I use my app normally, the scrolling is very smooth without significant lag. But if I keep the app (simulator) running on the "thumbnail grid view", and switch to other applications in Mac OS. After a while (maybe about 1 minute), when I switch back to the simulator, the scroll view gets stuck. It's hard to scroll it. If I click on something switching to another view and then switch back, everything is smooth again. So tricky.
I also tried the TTRemoteExamples which uses three20 to implement the grid view. It also gets stuck after switching between different applications in Mac OS (not in the iOS).
Then I tried not filling the customized cell with UIButton but 4 images. It didn't get stuck. So maybe the reason lies in the conflict between UITableViewCell and UIButton?
I don't know if it only happens on simulator or have potential performance problem when shipped to device (I haven't got the device to test on).
Apple's photo app will never be like this.
So I'm going to implement it from UIScrollView by myself to see if the problem is caused by the UITableView's mechanism. I still want to know the reason for the lag if anyone has come to it and solved it.
Sorry for my poor English, I hope you can catch my meaning.
Who cares what the simulator does, seriously. Let it fart magical evil fairies that hijack the world's financial system causing it to enter a world of collapse...oh wait, maybe it already did that.
Seriously though, look at using code like AQGridView. It's very stable, provides an interface very much like a tableview, and is used in many projects. You also avoid the nonsense that is Three20 going this route. It's win-win.
But remember, always, and I do mean always, care what your app does on a device, if it isn't doing the same thing on the simulator, don't worry about it, you shouldn't be testing on the sim 99% of the time anyway. Users interact with your app on their devices, not your simulator. :)
Referring to Subclassing UITableViewCell section in Table View Programming Guide for iOS,
I finally solved the problem by implementing my custom mimicking the way from the guide, without adding subviews to UITableViewCell.
Apparently, adding too many subviews, only 4 in my code although, caused the strange problem I mentioned above. So, NEVER ADD SUBVIEWS, especially those with UIImageView's in it, to the contentView of UITableViewCell or UITableViewCell itself.
Instead, keep data's in the customized UITableViewCell, and do every drawing related thing in drawRect, using -[UIImage drawAtPoint:] and -[NSString drawAtPoint:withFont:].
In fact, the Apple's guide has mentioned it. It's careless of me skimming the part.
However, I'm still curious about why, as I mentioned, it only occurs when you switch between applications in your Mac OS, not iOS. I don't know the reason indeed.