Swift - Selecting cells when having multiple custom cell-classes

Swift - Selecting cells when having multiple custom cell-classes

By : tanuj gyan
Date : November 22 2020, 10:38 AM
should help you out I have 2 custom cells that I need to set the selection properties for. Right now, I've used a boolean to tell the program that the cell is either type 1 or type 2, because I was just checking if the code was working. , Here is a Objective example of this:
code :
id cell = [tableView cellForRowAtIndexPath:indexPath];

if ([cell isKindOfClass:[PhotoCell2x class]]) {
else if([cell isKindOfClass:[EffectCell2x class]]){

Share : facebook icon twitter icon
Selecting a cell and changing the alpha of all cells in tableView - Swift

Selecting a cell and changing the alpha of all cells in tableView - Swift

By : Collen Tlaka
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , You'd want to set the alpha value in the cellForRowAtIndexPath, then simply reload that row when its tapped. This should preserve the alpha for that cell and set alpha to 1 on every other cell, even if the the user scrolls the cell offscreen.
code :
var selectedIndexPath:NSIndexPath?
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell:UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! UITableViewCell

    if let selectedIndexPath =  self.selectedIndexPath where indexPath.row == selectedIndexPath.row {
        cell.alpha = 0.5
    } else {
        cell.alpha = 1

    cell.labelText.text = self.data[indexPath.row]

    return cell

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    self.selectedIndexPath = indexPath
tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
Swift 3 - Problems in reusing cell with multiple custom cells

Swift 3 - Problems in reusing cell with multiple custom cells

By : Andrew Messing
Date : March 29 2020, 07:55 AM
this one helps. I've got problems when I scroll down in my UITableview. The table shows me cells with old content when the cell is reused. , Here:
code :
    } else {
        let cell = tableView.dequeueReusableCell(withIdentifier: "QuestionSingleChoiceStructureCellID", for: indexPath) as! SingleChoiceCell
        //cell.singleChoiceLabel.text = questStruct?.question
        cell.selectionStyle = UITableViewCellSelectionStyle.none
        return cell
Swift TableView multiple Custom cells, inrease number of row in from cell lead to crash

Swift TableView multiple Custom cells, inrease number of row in from cell lead to crash

By : Christian Arcadia
Date : March 29 2020, 07:55 AM
hop of those help? Your problem is in different types of registered cell and type you're trying to force cast it to. Like Xcode says you - TaskList.SwitchCell to TaskList.CategoryShowCell. Force casting happens at as! CategoryShowCell this place.
I suspect, that you are reregistering SwitchCell.self for categoryShowID. It can happen if your categoryShowID is equal to swichCellID.
XCUITest: selecting a CollectionView cell from multiple cells identifier with multiple cell prototypes

XCUITest: selecting a CollectionView cell from multiple cells identifier with multiple cell prototypes

By : Andrés Techera
Date : March 29 2020, 07:55 AM
help you fix your problem i've been trying to tap() the correct Collection View cell, I can manage to tap() when there is only 1 cell prototypes, but I cant manage to select the correct cell based on the cell identifier when there are many cell prototypes with different identifiers. . , you can do something like this to tap the second cell:
code :
let secondCell = app.collectionViews.children(matching:.any).element(boundBy: 1)
if secondCell.exists {
let predicate = NSPredicate(format: "label BEGINSWITH 'test'")
let cell = app.collectionViews.cells.element(matching: predicate)
Selecting multiple cells at a same time having same cell value

Selecting multiple cells at a same time having same cell value

By : user3063366
Date : March 29 2020, 07:55 AM
this will help in a worksheet I want to select the inputbox's input i.e. suppose "A" which is incurred in multiple cells in multiple location. I want to select all the cells referring to letter "A" at the same time. , Build a Union() and use it:
code :
Option Explicit

Sub SelectBattleship()
    Dim BattleShip As Range
    Dim Name As String
    Dim store As Variant
    Dim cell As Range, rSelect As Range

    Set BattleShip = Range("A1:J10")

    Name = InputBox("Value?")

    For Each cell In BattleShip
        If cell.Value = Name Then
            If rSelect Is Nothing Then
                Set rSelect = cell
                Set rSelect = Union(rSelect, cell)
            End If
        End If
    Next cell
    If rSelect Is Nothing Then

    End If

End Sub
Related Posts Related Posts :
  • Programmatically set size of UIView from Storyboard
  • Navigation bar blink
  • Web services issue on POST method
  • Parse.com error 'Method not allowed when Pinning is enabled.' when I use a PFQueryTableViewController subclass
  • Swift can't send URLRequest at all?
  • No Provisiong profiles with a valid signing identity were found and Failed to locate or generate matching signing assets
  • iOS: how to set httponly flag for NSHTTPCookie
  • How to get the mac address of a beacon in objective-c without knowing its UUID, major and minor values?
  • tableView is not showing data from JSON in swift
  • iTunes reject app for date of birth
  • SWIFT reporting "Extra argument in call" - works in Playground
  • save data depending on passed value in swift
  • webview not showing on full Screen of iphone 6
  • Location Notification's based on Latest iOS Feature
  • Adjusting Height of UITableViewCell
  • How to show five digit unicode in iphone
  • unwind doesn't work
  • Confusion about coordinates, frames & child nodes in SpriteKit on iOS?
  • If Statements not being recognized by Xcode
  • readonly property in RubyMotion
  • 'No available types for source 1' when the app runs on my device(IPhone 6) swift
  • IOS:Remove view when clicked in background
  • Removing "\" from URL in iOS Swift
  • iOS - Send an email automatically (NOT from user's account)
  • The usage of NSNotificationCenter in the relationship of parent and children
  • When do Apple auto-renewable subscriptions renew?
  • Unknown large spacing between x-axis label and base of plot in core-plot
  • How do I change the displayed time format after NSTimer is initiated?
  • Swift JSON breaks when [ ] are used
  • Secure Memory For Swift Objects
  • didSelectItemAtIndexPath doesn't work normally
  • Swift Documentation Comments
  • Is there a simple way to assign a value only once(first time) inside a loop/repeatedly running method?
  • Play sound in while app in background
  • If I have an embedded unrestricted webview, does that mean I have third-party content?
  • UITapGestureRecognizer on UIScrollView
  • App does not respond to hardware volume changes on iPad
  • troubleshoot asp.net web app on iOS
  • What size should my tab bar item icons be?
  • Parse.com Facebook authorize never calls completion handler
  • Implementing iAds on a SceneKit view
  • UIAccessibility and Apple Pay voice-over interaction issue
  • Getting objectForKeyedSubscript unrecognized selector when parsing data in table view
  • Execute action when back bar button of UINavigationController is pressed
  • iOS Table View - Set tag on cell or label?
  • Preferred approach for changing UITableViewCell content based on cell width
  • NSDateformatter dateFromString AnyObject
  • Type specifier for NSMutableArray?
  • iOS7 slideout drawer draggable bug
  • Fetch Core Data entity with a filtered set of child elements based on a property
  • UILabel AutoResize Swift
  • Table View Cell Prototype from Storyboard not initializing subviews
  • Best way to implement view like map
  • Adding a tap gesture to a UIImageView to change a UILabel?
  • Minimum OS X and xcode requirements for ios 8.1 development
  • Changing the text of the Cancel button in the default TouchID dialog
  • iOS timing between taps
  • Swift: How do I link an action to a view inside of a tableViewCell?
  • Value for frame.size.height is always the same regardless of height of view
  • WatchKit / Apple Watch API: vibrations of custom length?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org