logo
down
shadow

iOS Table View - Set tag on cell or label?


iOS Table View - Set tag on cell or label?

By : Satheesh kotra
Date : November 22 2020, 10:38 AM
I wish this helpful for you I'm not familiar with the tutorial, but using tags to identify labels within cells this way is not a good idea.
The cell should know about it's own label. It's far better to just have a method on the cell that you can pass the text to, and then let the cell take care of displaying the text in the cell.
code :


Share : facebook icon twitter icon
How can I use text from a table view cell and display it as a label in a parent view controller?

How can I use text from a table view cell and display it as a label in a parent view controller?


By : Timur Shafeev
Date : March 29 2020, 07:55 AM
it should still fix some issue Yes, you would use a delegate method to pass the data back to the parent. Since you are using some kind of array datasource to populate the table, you already have access to those values in a clean format (instead of pulling from the tableViewCell's hierarchy).
From your table vc:
code :
@protocol MyTableViewDelegate
-(void)didSelectText:(NSString *)text;
@end
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // It's good practice to do this check first
    if([self.delegate respondsToSelector:@selector(didSelectText:)]){
          //basically pull the value out of your data source and send it to the delegate
        [self.delegate didSelectText: self.arrayDataSource[indexPath.section][indexPath.row]];
        [self dismissViewControllerAnimated:YES completion:nil];
    }
}
Label cut off on Table View Cell

Label cut off on Table View Cell


By : Riyad Salam
Date : March 29 2020, 07:55 AM
hop of those help? The top and bottom text label for my tableView cell appears to be cutting off. It is not clipped in the Xcode preview or the storyboard view. How do I make the labels extend to fill the entire row? , There are a couple of "potential solutions":
How to show a table view header's label in the left part of the same table view cell ?

How to show a table view header's label in the left part of the same table view cell ?


By : mar1982
Date : March 29 2020, 07:55 AM
seems to work fine You can create a headerView and add a label to it and set the text alignment of the header view to left or as per your need.
code :
  override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
    let headerView = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 50))
    headerView.layer.borderWidth = 2
    let myLabel = UILabel()
    myLabel.frame = CGRectMake(0, 0, tableView.frame.width - 70, 50)
    myLabel.font = UIFont.boldSystemFontOfSize(18)
    myLabel.textColor = UIColor.whiteColor()
    myLabel.textAlignment = .Left
    myLabel.text = "This is a left alignmen" 
    headerView.addSubview(myLabel)
    return headerView
    }
Cell label Does not catching value in table view

Cell label Does not catching value in table view


By : user2464941
Date : March 29 2020, 07:55 AM
like below fixes the issue I believe the problem is that you are looping through the entire array every time you get a request for a cell. What you probably want to do is get the number for the indexPath.row and loop through the onlineUserArray to find the status.
Something like this (I don't know your exact data structure, but this should be along the right lines):
code :
    // inside cellForRowAt

    cell = singleChatRoomsList.dequeueReusableCell(withIdentifier: "SingleRoomCellView") as! ChatRoomCellView

    // just to make it easy to see what's going on in the debug console
    print(indexPath)

    let phone = numbers[indexPath.row]

    for number in onlineUserArray
    {
        print(number)
        if number.phone == phone
        {
            if number.status == 1
            {
                print("Matched")
                cell.theLabel.backgroundColor = #colorLiteral(red: 0.08950354904, green: 0.807744801, blue: 0.07534810156, alpha: 1)
            }
            else if number.status == 0
            {
                cell.theLabel.backgroundColor = #colorLiteral(red: 0.6666666865, green: 0.6666666865, blue: 0.6666666865, alpha: 1)
            }
            else
            {
                cell.theLabel.backgroundColor = UIColor.clear
            }
            print("found a match, so break out of the loop")
            break
        }
    }
customize table view cell with own label

customize table view cell with own label


By : Delmos
Date : March 29 2020, 07:55 AM
Does that help That is because UITableViewCell don't have a property named nameLabel. Assigning textLabel.text is right Or you can implement custom cell class, and there have fields with the proper names for you Then instead of
Related Posts Related Posts :
  • Delete Core Data Entry from Table View Controller
  • How to unload UIViewcontroller from memory?
  • Compressing UIImage as Far as Possible?
  • Optimizing workflow to update internally owned cocoapods dependencies?
  • Formatting an NSDate with Abbreviated Month/Day Names
  • I'm creating a quiz game with 4 answers and I want to add score
  • Tap Gesture to Hide Navigation Bar, Tab Bar, and Status Bar
  • FBSessionStateClosedLoginFailed when I am logged in through Settings
  • CGRect positioning according to center point
  • iOS: Update table view datasource with animations without core data
  • iOS : Where to start for AliPay integration?
  • Routing App Coverage File missing but not needed?
  • Drawing on a zoomable view
  • Append NSStrings and NSNumber to NSMutableArrays and make NSMutable dictionary
  • Terminating app due to uncaught exception 'NSRangeException' when calling dequeueReusableCellWithReuseIdentifier:forInde
  • Collision without physics (Cocos2D + Box2D iOS)
  • Creating a percentage based iOS layout
  • Update tableView row from AppDelegate Swift 4
  • Assigning return value of a class method to a variable error
  • how to display circular progress in delphi ios apps?
  • I can't figure how to fix this Expected identifier or '('
  • How to Test APIs in Swift 4?
  • Link error /Build/Products/Debug-iphonesimulator file not found
  • working with a very large JSON object in iOS
  • Turn off part of the iPhone Screen
  • Phonegap 3.0 app with facebook login using xCode
  • How to add interstitial admob ads to my ios project
  • adding tapku calendar to ios app
  • Add an alertcontroller in a global swift file?
  • Take square image with Cordova (Phonegap) Camera API?
  • Amazon S3 policy allowing only upload not overwrite
  • How to change the UILabel content by tapping?
  • Adding checkmark to selected table cell also checks another table cell
  • UICollectionView cellForItemAtIndexPath indexPath row is nil
  • Resize and set quality on JPEG image while retaining EXIF in iOS
  • How to push rootviewcontroller in Ios
  • How to add UIBarbuttonItem at centre on UInavigationbar in iOS
  • Would this IOS device test crash be expected
  • PickerView not showing any values
  • How to set root view controller in storyboard animated with navigation controller programmatically
  • Can anyone suggest me the effective way to deal with s3 upload fail because of timezone difference issue?
  • Getting list of files in documents folder
  • Error while using Realm Object as a singleton. Is it a good idea?
  • inserting into SQLite database
  • More nodes than I should
  • Facebook IOS SDK navigate to another controller after login not working
  • Swift Array - use "Contains" of type AnyObject
  • Sidebar menu with indicate navigationbar on iOS
  • 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
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org