Questions tagged [indexpath]
155 questions
21
votes
6 answers
Swift 3 Array, remove more than one item at once, with .remove(at: i)
Is it possible to remove more than one item from an array, at the same time, using index locations as per .remove(at: i) kind of like:
Pseudo code:
myArray.remove(at: 3, 5, 8, 12)
And if so, what's the syntax for doing this?
UPDATE:
I was trying…
Confused
- 5,839
- 6
- 26
- 65
9
votes
4 answers
How to display ads within a collection view
I'm trying to add some banner ads randomly inside my collectionView.
Each collectionView cell would be a basic image (black square here to make things easier) populated dynamically from an array (let's say it's a really long array and call it…
jellyfish6
- 187
- 2
- 12
7
votes
4 answers
How to check if IndexPath is valid?
Prior to swift 3, i used to use for example:
let path = self.tableView.indexPathForSelectedRow
if (path != NSNotFound) {
//do something
}
But now, since i use IndexPath class in swift3, i'm looking for the equivalent for the path != NSNotFound…
Lirik
- 2,948
- 27
- 30
7
votes
4 answers
How to get indexpath from row index Swift
I am loading an array to UIcollectionview(later will add other data) . I want to select collection view item randomly as:
var indexpath = Int(arc4random_uniform(UInt32(items.count)-1)
self.collectionview.selectitem(at: **indexpath**, animated:true…
Saira Nawaz
- 670
- 2
- 10
- 23
4
votes
5 answers
Get all indexPaths in a section
I need to reload the section excluding the header after I do some sort on my tableview data. That's to say I just want to reload all the rows in the section. But I don't find a easy way to make it after I search for a…
LF00
- 22,077
- 20
- 117
- 225
4
votes
1 answer
different types of cells in one collectionView
I have 4 different collectionViews in one controller, and in the first collectionView I want to have 3 different cells display. In the below code the app does not crash, but in the first indexPath.item of 0 only case 0: ("cellId") loads. It does not…
user3708224
- 1,129
- 3
- 17
- 36
3
votes
3 answers
Get IndexPath of CollectionViewCell outside of Cell
First of all I am a newbie in swift, so be gentle. I have a problem fetching the indexPath of the cell outside of the cell. I want to get that index path to a function and use it to send the content to another view. The image was created…
Marian Petrisor
- 213
- 2
- 14
3
votes
2 answers
RxSwift access to indexPath.section
guys Im totally new in Rxswift, is there is a way to do this scenario in RxSwift ?
What I got is this.. but problem is i dont have indexPath
datasource.sectionModels
.asObservable()
.bindTo(tableView.rx.items) { tableView, row,…
Denis Kakačka
- 457
- 1
- 6
- 19
3
votes
2 answers
UICollectionView cellForItemAt indexPath is skipping row indexes in iOS 10
I have UICollectionView with horizontal scrolling and paging. When I scroll to next or previous page for the first time or change scrolling direction from left to right, value of indexPath.row in cellForItemAtIndexPath is changing by 3 not 1. Then…
Roman Siro
- 226
- 1
- 11
2
votes
2 answers
Swift: Convert IndexSet to [IndexPath]
I want to get [IndexPath] from IndexSet in Swift 5.
There is a question to convert NSIndexSet to Array in Objective-C.
But there is no method enumerateIndexesUsingBlock in Swift 5.
Who knows the way?
Emre Kayaoglu
- 260
- 1
- 2
- 17
2
votes
3 answers
how to check indexpath.row == 4 * n by n += 1
Problem Statement : I want to dequeueReusableCell "PromotionCellIdentifier" cells everywhere indexPath.row == 4 * n but it only run dequeueReusableCell "PromotionCellIdentifier" one time . I need a solution.
It have only dequeueReusableCell…
2
votes
2 answers
Append Array Through If Statement
So, I am making an app that requires to select various things. You can select these by swiping to the right of the UITableView. I am using a UIContextualAction and I am using a switch statement to order out the functions and executable statements.…
Jorge Zapata
- 87
- 4
2
votes
1 answer
Set a circle label for a separate Cell of CollectionView [Swift]
I'm trying to draw a circle for a visible cell of CollectionView, look like this
I tried to make it trough addSubview and then removeFromSuperview the previous label, but it doesn't work
let myIndex1 = IndexPath(row: 0, section: 0)
let…
Diana
- 533
- 7
- 15
2
votes
1 answer
ScrollToRow does not work when said row is near the bottom of the table view
I have a cell class which implements a textfield delegate. In this delegate I am calling a function to tell the tableview to scroll to a specific row based off an indexPath. This works in most cases but not when the row is at the bottom of the table…
user2363025
- 5,389
- 15
- 41
- 86
2
votes
4 answers
Disclosure indicator to specific cell in static TableView in Swift
I created a static TableView and I would like to add or remove a disclosure indicator depending if we are consulting our own account or a guest account.
This is what I would like :
let index = IndexPath(row: 4, section: 0)
let cell =…
KevinB
- 2,006
- 3
- 18
- 38