Constraints not working in TableViewCell - ios

I'm learning how to use CoreData to store images, and I'm making a blog reader. I have a view That shows all the info saved as a list and when you click it takes you to that article. My problem is that I can't make TableViewCells look as intended. I have added the constraints and not a single of them is being placed.
Here are my constraints:
And this is the result:
I've deleted them, cleaned, closed xCode, put them again and the same result. Found this answer, checked and nothing. Also this one. In the same project, I have another TableView and it works fine, any ideas why this is happening? Thanks a lot!

Looks like image is overflowing form the container. Try this
Set the UIImageView content mode to UIViewContentModeScaleAspectFill
Set UIImageView clipToBounds to true.

It seems like issue not because of constraints. it because of image to solution for this issue
You have two option to solve this
1) Via code
cell.YOUR_IMAGE_VIEW.clipsToBounds = true
2) Via Interface Builder
Hope this will help you

Related

Xcode 8 Adding Layout Margins Crash

When I try to add layout margins to a label on a TableViewCell, using the right panel on Xcode, I try to add Explicit Margins (top, Left, Bottom, Right). But, as soon as I input a number value, or tap the arrow to change the value, Xcode crashes.
I've attached a photo to show the panel I am trying to add the layout margins in, and where it crashes.
Any ideas why it wont let me adjust the margins?
try to clear the constraints, connect/ reconnect the outlet and apply new constraints.
Had that problem. Its Xcode bug. Already fixed, so don't worry :)
I was facing similar problem.
The answer that I found and which I used in real project (but for UICollectionView) was to get the outlet of CollectionViewFlowLayout and to define the margins (line spacing and item spacing) by myself in code.
For example
collectionViewFlowLayout.minimumLineSpacing = getCollectionViewWidth() * 0.05
Where getCollectionViewWidth() is a function, that returns the size of collection view (for different screens it will be different) and 0.05 is just random coefficient.
I hope it may someway help you, you can feel free to ask anything else.
If you have crash when you add margins on any view in your storyboard you can try to get their outlets as well and to redefine their frames. It's kinda bad style, but if you won't figure out the problem its the only one I can recommend to you and which I used myself.
Also try to Clean project by clicking Product - Clean in you task bar when in X-Code.
Clear all the constraints and try from applying one by one. That way you can resolve this issue.
Please remove all the constraint applied and connected to the outlet. And Try to apply new constraints.
Some time we delete Outlet from you files .h or .m or swift file which was connected to view in Storyboard or xibs at that time this problem occurs.
Clearing all constraints is the way to go. Look around every nook and cranny and right click every little thing in both your Main.storyboard and the ViewControllerScene menu to its immediate left. If you can get the formatting back to its most base level your constraints will work fine!
Clear all the constraints and try from applying one by one.and take .xib file and connecte with Table view Cell
Xcode stores some user state information inside the Xcode project file, which is really a folder. That state information might have become corrupted. You can normally throw away everything inside your .xcodeproj folder except the project.pbxproj file. This might fix your problem.
Open up the folder containing your .xcodeproj file. Right-click the .xcodeproj file and choose Show Package Contents. Then throw away everything except the project.pbxproj file.
If you know what an Xcode workspace is, and you're actually making use of it, you might not have a project.xcworkspace file to throw away, or you might not want to throw it away. But if you don't know what an Xcode workspace is, then you're not using it so you can just throw away project.xcworkspace. Xcode will recreate it automatically.
see This Link

UITableViewCell overlaps the delete button in the UITableView

As shown in the image below when I enable the edit mode for the tableview and click the (-) button the delete button is hidden behind the UITAbleViewCell.
Not sure what causing the issue as I have used same similar type of custom UITAbleVeiwCells and delete worked without any problem.
Can someone enlighten me where I'm going wrong and why cell behaves in peculiar way.
I think cell.clipsToBounds = YES; can resolve the issue.
Also try using the imageView.maskToBounds = YES;
I don't know if you are having the images locally or you are downloading it from server. It could happen that the image is not downloaded when the delete button is shown and when it's downloaded the image is shown up as per it's size (contentMode). That's why I think setting imageView.masksToBounds could resolve the issue.
decrease the width of the imageview or view whatever that you gives to the image....

Xcode Interfacebuilder bug?

I got a problem in the Xcode project.
below image shown UITabbar problem. I thought it's a Interface builder bugs.
UITabbar showing a dark color. That only shown a root & one-depth ViewController.
How can I solve it?
Thanks.
== Modified ==
The problem suddenly appeared.
It is not known whether the problem is caused what.
TabbarItem area is like a shown bug as image.
I hope Tabbar area to be displayed correctly.
I tried to various way to solve the problem.
tried ways as a below :
regenerate xcode project and then copy storyboard. => fail
regenerate storyboard and then copy partial elements in storyboard. => fail
regenerate all of them. => I did not try yet.(have too much elements. I want to avoid like this way.)
Interest point is sometimes display correctly. When I first open a simple storyboard file(Default UITabbar Project's main storyboard) like a below image.
it bring to me confused.
I'll summarize what I know about storyboard that may cause similar issue...
Assigning images that have incompatible width:height ratios to tab
bar items
Not assigning any images or not using any system images for tab bar
items
Hope this can help anyone else that has similar issues...

iOS - IB view mode

I'm just curious, but what is the IB View Mode even used for?
I've changed this many times with no effect? Can someone please explain.
It changes the way a view is filled with an image.
Try to set an image and change the values to see the difference.

Using UIScrollview to display .xib as different pages?

I think im missing something fundamental here because everyone seems to be able to do this simple task. Im trying to create an app that is very similar in presentation to the iPhone home screen (paging). I plan to have several pages that each have their own unique content. My understanding is that I can use UIScrollview to display and animate these pages/xib's but I have tried what seems like everything and am frustrated by the lack of instructions for newbs like me.
What I understand so far:
Declare IBOutlet UIScrollView *scroller
Set options in .m or in scrollview object via IB
connect fileowner of main .xib to *scroller
connect fileowner of main .xib to delegate
then somehow call in the other xib to load as the pages for the scrollview.
One thing i have found is that most of the tutorials and source codes i get are outdated or look different. Im using xcode 4.2. ANY HELP is greatly appreciated. Thanks!
I'm also a newbie so may be I don't understand your problem exactly but if you want to represent your scroll view in pages you should enable paging for it:
yourCoolScrollView.pagingEnabled = YES;

Resources