here's my issue:
I have a UITableView and in each cell I display some UILabels, like below:
----------------
| "A" |
----------------
| "B" |
----------------
| "C" |
----------------
Each cell is tap-able and when tap it pushes to another view to allow user to add some cell content. When user finish adding, the view pops back.
I want to see the UITable cell is statically updated with a new label that user added. For example, if user added some content to the first cell (previously with one label "a"), then after view pops back the cell should have two labels, which should look like:
----------------
| "A" |
| "New" |
----------------
| "B" |
----------------
| "C" |
----------------
I don't want to reload the entire table (which will drain data and lost previous cell position). Is there a way I can re-load this specific cell with new height/content? or statically adjust the cell-height?
Thank you
Yes you can reload particular cell in table view while relaoding the cell you can set cell height.
NSArray* rowsToReload = [NSArray arrayWithObjects:self.selectdIndexPath, nil];
[self.tableview reloadRowsAtIndexPaths:rowsToReload withRowAnimation:UITableViewRowAnimationNone];
Related
I have a screen with UICollectionView. This is layout of my screen in portrait:
| cell1 |
| cell2 |
| cell3 |
| cell4 |
| cell5 |
Now when I rotate device to landscape here is how it looks.
| cell1 cell2 |
| cell3 cell4 |
| cell5 |
The problem is that I need cells to stay in 1 column and have specific width and this is something I cannot achieve.
The collection view is using IGListKit for layout and self-sizing cells like in IGListKit example project, due to this and specific project structure I have to use custom subclass of UICollectionViewFlowLayout for any custom layout as I cannot override delegates. As soon as I increase the width of cell they align properly in 1 column. However, it seems that because cell width takes such small amount of space it automatically makes 2 columns in collection view. How do I keep one column after rotation while still having desired cell width using custom UICollectionViewFlowLayout?
Now, I have one UITableviewCell like this:
|--------------------|
| TitleLabelxxxxxx |
| SubtitleLabelxxx |
| tagView(Labels ) |
|____________________|
Tagview : https://github.com/ElaWorkshop/TagListView
TitleLabel and subtitleLabel are not one line.
I receive data from the backend and set the data to tagViews, titleLabel and subtitleLabel.
I used a storyboard to make this TableviewCell.
I used autoLayout to preset the height of the Tagview.
The value of height is more than or Equal 34( one line height).
If the tagViews has one line label, the TableviewCell renders perfectly.
If the tagViews has several tags:
When the TableviewCell first shows, the TableviewCell does not render all tags which are rendered in the tagView.
When I scroll this tableView, all TableviewCell will render perfectly after they scroll into the screen.
I used the tableView.rowHeight = UITableView.automaticDimension to set the height of TableviewCell.
This way can't calculate the perfect height value when the cell first renders.
The answer:
https://github.com/ElaWorkshop/TagListView/issues/191
I used this way to fix the bug.
So I have a collection view like shown below:
----------- ----------------
| some text | | Some more text |
----------- ----------------
----------------------- -----------------------
| Some really Long text | | Some longer text here |
----------------------- -----------------------
And I would like it to be:
----------- ----------------
| some text | | Some more text |
----------- ----------------
----------------------- -----------------------
| Some really Long text | | Some longer text here |
----------------------- -----------------------
I was able to get my cells to dynamically adjust their width to allow for a label to display its text, but I would like all of the cells to be left aligned with their section insets instead of being centered.
Edit:
I've tried a lot of things so far, but here is the last thing (doesn't actually work)
class LeftAlignedCollectionViewFlowLayout: UICollectionViewFlowLayout {
override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
let attributesForElementsInRect = super.layoutAttributesForElements(in: rect)
var newAttributesForElementsInRect = [UICollectionViewLayoutAttributes]()
for attributes in attributesForElementsInRect! {
let refAttributes = attributes
refAttributes.frame.origin.x = self.sectionInset.left + 8
newAttributesForElementsInRect.append(refAttributes)
}
return newAttributesForElementsInRect
}
}
I'm not sure if it would be easier to set the widths of each cell in a section equal to each other instead, that would force all of the cells in the section to aligned with each other instead of centering inside of the section. I'm not sure how to approach this though - the sizeForItemAt seems like palace to start, but I don't want to override auto layout setting the widths dynamically for the labels.
So here is what I'm trying to do:
I have a navigation controller N that manages a bunch of view controllers. Now depending on a given flag, another view controller B should be shown. The thing is I want B to always sit on top and at the bottom of the navigation controller N.
Any actions that happen in the navigation controller should also be presented in that specific navigation controller and not expand to the area of B.
The layout should basically look like if the navigation controller is only visible
_________
| |
| |
| N |
| |
| |
---------
And this is how it is suppose to look when the flag is set to true
_________
| |
| |
| N |
|_______|
| B |
---------
I'm trying to use View Controller Containment and was able to add B's view to N's hierarchy, but I can't figure out how to resize and reposition N and how to make sure that all new controllers that are loaded from N are contained in N's bounds.
I'm adding B as follows:
let b = BViewController()
presentedViewController?.addChildViewController(BViewController())
presentedViewController?.view.addSubview(b.view)
b.didMove(toParentViewController: presentedViewController!)
Where presentedViewController is defined as
var presentedViewController: UIViewController? {
var viewController = AppDelegate.instance?.window?.rootViewController
while(viewController?.presentedViewController != nil) {
viewController = viewController?.presentedViewController
}
return viewController
}
Any pointers how I can achieve this behavior?
Basically the effect I'm trying to achieve is what Apple does with the blue rectangle when an app is currently using location services. The blue rectangle pushes all the other views down.
I am trying to create a View that contains many subviews and can contain many tableviews.
Need is to enable scroll of all the subviews.
Actually I created scroll view and put it into superView. Then i put all the views inside that scroll but i have a lot of problems with putting tableviews inside that scroll using AutoLayout. I dont want a scroll inside tableViews, all i need is to enable clicks each tableView i create. I would like to listen to all of your suggestions how can I easily create this View.
A scrollview inside of a scrollview is hard to handle. Maybe it's worth to redesign your data model by combine the contents?
e.g. (assuming that each table contains 2 Labels)
image -> Row cell 0 of type A OR TableHeader
Label -> Row cell 1 of type B
Label -> Row cell 2 of type B
Label -> Row cell 3 of type B
Label -> Row cell 4 of type B
Table 1 Label 1 -> Row cell 5 of type C
Table 1 Label 2 -> Row cell 6 of type C
Label -> Row cell 7 of type B
Table 2 Label 1 -> Row cell 8 of type C
Table 2 Label 2 -> Row cell 9 of type C
Label -> Row cell 10 of type B
Table 3 Label 1 -> Row cell 11 of type C
Table 3 Label 2 -> Row cell 12 of type C
...
Button -> Row cell n of type D OR TableFooter
Now you can fill your table like a normal table without special solution.