IB displays tvOS tableviewcells with weird frames - xcode

I am having weird bugs in IB for tvOS tableviewcells.
Since this is my first tvOS project, I don't know if it is intended or not but tableviewcell's content view's width is notably smaller than actual cell.
When I try to add any subview(UILabel, UIButton or UIView) its actual frame and content are different.
Lastly, when I try to resize any subview inside UITableViewCell, its frame changes immediately.
Screenrecord1
I use the latest version of Xcode, Version 9.2 (9C40b). Has anyone else experienced this issue before?

Related

UITableviewcell width not filling the screen

I don't know if this is a bug with AutoLayout or Xcode but I've realised that if I run my application on a device which isn't the same size as the device in my storyboard, the elements are adopting the incorrect size.
I.e. Selecting View as iPhone SE and running the application on an iPhone 7+ The size of my tableview is the width of an iPhone SE screen, this fixes itself when I reload the view and then it then adopts the width of the iPhone 7+ screen.
Just a note as well the table view doesn't have a fixed width and is pinned to the top, bottom, left and right with 0 spacing and also I'm changing the height of the cells programmatically in code if this could affect it at all as well.
Video: https://drive.google.com/open?id=0B0QLbDLfJn6_YzljUGg4RTUwaTg
Views that come from a xib (or storyboard) have their IB frame values when they are created, before they are added to the view hierarchy. So a case like you describe is probably that something is accessing a view loaded from a xib before it has become part of the layout process and resized.
This would also explain why it's fixed when you go away and come back. The first time, it got the values before they were final, but the second time the values are already final and correct.
Layout code called fromviewDidLoad() for view controllers, or awakeFromNib() or initWith(coder:) for views is the likely cause. Layout code called from viewDidLoad() is especially problematic because it was fine up to iPhone 5s, but would now cause this problem.
It's impossible to say what exactly the issue just from this. From the NSLog statements visible in the video, the issue is whatever code calls that "weather view width". That is being called too early in the layout process. It needs to go in viewWillAppear or viewWillLayoutSubviews to make sure the correct values are ready for whatever calculation is dependent on that. Hope this helps.
I can't seem to recreate this. I would recommend double checking for any updates for Xcode and the Developer tools (softwareupdate --install -a).
Incase you haven't, restart Xcode.
EDIT: Disregard this answer, please read Mike Sand's post.
Try self.view.layoutIfNeeded in viewDidLoad or in viewWillAppear

Text starting at wrong position in textview in Xcode 6

There's no code involved at the moment, only storyboard or xib files as far as the textview is concerned. This is what I get when running the app on my iPhone 5s or via the simulator.
I'm using auto layout and size classes with the option any width-any height. An imageview at the top, then a label, then the textview.
Here's a picture of the screen. As you can see, it looks as if the text is starting behind the label, but the textview's y is after the label and the constraints seem all correct according to Xcode 6. It works fine on iPad.
Any idea of what I'm doing wrong?
I've found a way round it: textview should have no scrolling enabled and should be put in a scrollview instead, which will do the actual scrolling. Need to add constraints to both.

xcode ios 7 fixed height of tableview with statusbar change and in ib

I need to make my tableview not change height at all. Not shrink when statusbar is changed. I am using storyboard and i have another viewcontroller with a embeded tableview where the tableviews height stays the same no matter what.
In interface builder when switching from 3.5" to 4" the tableview changes size. I have fixed this by setting height programmatically. However the height changes when statusbar is changed. I cant seem to find the property in IB that turns off this autosizing feature for my second tableview. Im am not using auto layouts. I dont know why the height allways stays the same on my other tableview in my other viewcontroller.. Can someone please help me out??
Auto resize subviews was the property for the main view that was enabled . Disabling this fixed it.

Xcode 5, storyboard update image position issues

When I open up my Xcode 4.x project in Xcode 5 and load a Storyboard some strange things are occurring. Mainly, some of my images are getting re-sized and positioned. The size always gets set to 0,0 and the position is somewhere WAY off screen. Values like -3007,12824. This is an app with a massive amount of storyboard layout and while it hasn't messed with all the images, there are easily 500+ that have this problem.
for example this
<rect key="frame" x="403" y="134" width="572" height="486"/>
changed to
<rect key="frame" x="-815" y="1490" width="0.0" height="0.0"/>
I've tried setting the storyboard to Xcode 4.6 version, but no effect. Anyone know why this is happening and how to prevent it (short of manually discarding all the changes I don't want)?
edit: I am using the GM Seed for Xcode 5.
I found this post on the Apple Developer forums which seems to imply this is a bug. I've submitted the appropriate radars to Apple to help the find the root cause (as they've suggested).
In the meantime, I have a simple process for converting my storyboard.
Open them in Xcode 5.
Say I want to commit the changes (we all use source control, right?)
Select each storyboard in the list of modified files, go down the XML diffs and discard any changes which move my images. They are fairly easy to spot.
Add a comment and finish the commit.
After the initial conversion, from 4.x -> 5, Xcode screwed with the location of my images. While it's an annoying process, it's a lot quicker than either re-creating the storyboard or manually trying to move items back to their original position.
Oh yeah... and please file Radars with Apple so they can solve the issue. :)
I encountered this issue as well for some storyboards when I switched between iOS 6 view and iOS 7 view. Only workaround that I have found was to recreate the storyboard from scratch (using XCode 5.)
I had the same problem, after loading an existing Storyboard into Xcode 5, it got automatically updated to the new format, and all the image views were missing.
Turns out the view hierarchies were intact, only the frames were messed up. I went through and fixed all the image view frames, and that fixed the project.
Well, I've found that swapping NSBoxes for NSView fix it and let its contents rest in peace, but...
I have a NSTableCellView with a NSTextField. I set the NSTextField position, clean and build and I do can see my NSTextField in its position. But, if instead of building while I have this NSWindow ON the screen, I build the project while displaying another NSWindow the position of the NSTextField is modified to strange values. Uffff, I don't know what to do next. Any hints?
Got it!!! With XCode 5, if you hide a NSTableColumn and try to modify de NSTableCellView's width, you'll find that x=-0 (?) and width=0. No matter how hard you try to change it. It won´t work. The only way to set the x position and width is to unhide the NSTableColumn, adjust de x and width and then hide it again. It took me a while to get across the solution. I hope that Apple makes something about it.

Floating UIView on UITableView broken in iOS6

In my app i have UIView that floats at the top of a UITableView (Visualise:Attached to the bottom of the navigation Bar), under iOS5 i was enabling it to float at the top using these lines of code in scrollViewDidScroll
// get the table and buttonView bounds
CGRect tableBounds = self.tableView.bounds;
CGRect buttonViewFrame = self.buttonView.frame;
// make sure the buttonView at the table's original x and y as the content moves
self.buttonView.frame = CGRectMake(tableBounds.origin.x,tableBounds.origin.y,buttonViewFrame.size.width,buttonViewFrame.size.height);
This however no longer seems to work in iOS6, does anyone know why or how to fix the problem? I'm supporting iOS5 and above.
Having looked through the iOS6 release notes i found this...
Note that you can make a subview of the scroll view appear to float (not scroll) over the other scrolling content by creating constraints between the view and a view outside the scroll view’s subtree, such as the scroll view’s superview.
How would I set this up in code as Im not using AutoLayout in storyboards as I'm still supporting iOS5. It would also be great if anyone can enlighten me as to why the code i was using in iOS5 no longer works in 6.

Resources