logo
down
shadow

Change Data with Switch on UITableViewCell


Change Data with Switch on UITableViewCell

By : sandeep
Date : November 22 2020, 02:59 PM
help you fix your problem Now you have default value from switch when your cell is created. To set new value for dataModel in ViewController when your switch state changed you can use delegate mechanism.
Create protocol for your action:
code :
protocol SwitchChangedDelegate {
    func changeStateTo(isOn: Bool, row: Int)
}
class ProfileViewController: UIViewController, WCSessionDelegate, UITableViewDataSource, UITableViewDelegate, SwitchChangedDelegate {
    ...
    func changeStateTo(isOn: Bool, row: Int) {
        // here update your dataModel
        profile.artists[row].display = isOn
    }
    ...
}
var delegate: SwitchChangedDelegate?
var row: Int?
cell.delegate = self
cell.row = indexPath.row
@IBAction func changedBoolValue(sender: UISwitch) {
    ...
    self.delegate?.changeStateTo(sender.on, row: row)
}


Share : facebook icon twitter icon
Change Height of UITableViewCell from within the UITableViewCell inherited class when UITextField receive focus

Change Height of UITableViewCell from within the UITableViewCell inherited class when UITextField receive focus


By : Tom Hauff
Date : March 29 2020, 07:55 AM
To fix this issue You must have a link between the cell and the table view controller. Since you are already creating your custom cell in your controller the easiest way would be to use the delegate pattern.
code :
@class CustomTableViewCell;

@protocol CustomTableViewCellDelegate 
- (void)customTableViewCellDidEnterTextMode:(CustomTableViewCell *)cell;
@end

@protocol (nonatomic, assign) id<CustomTableViewCellDelegate> delegate;
[self.delegate customTableViewCellDidEnterTextMode:self];
- (void)customTableViewCellDidEnterTextMode:(CustomTableViewCell *)cell {
  self.editingIndexPath = [self.tableView indexPathForCell:cell];
  // from Jablair's answer
  [tableView beginUpdates];
  [tableView endUpdates];
}
iPhone SDK - Passing Data in an Array that is NOT shown in a UITableViewCell when that UITableViewCell is Selected

iPhone SDK - Passing Data in an Array that is NOT shown in a UITableViewCell when that UITableViewCell is Selected


By : user2948576
Date : March 29 2020, 07:55 AM
Hope that helps When you setup the UITableViewCell in tableView:cellForRowAtIndexPath:, you're using data from a certain index in the array of results, based on the index path of the cell.
The easiest way to do what you ask is to use the index path for the selected cell and perform the same calculation as above to find that certain index. Then you can fetch everything you need from the original array. That would look something like this:
code :
- (NSUInteger)arrayIndexFromIndexPath:(NSIndexPath *)path {
    // You could inline this, if you like.
    return path.row;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)path {
    NSUInteger index = [self arrayIndexFromIndexPath:path];
    NSDictionary *data = [self.dataArray objectAtIndex:index];

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:...];
    if (!cell) {
        cell = [[[UITableViewCell alloc] initWithStyle:... reuseIdentifier:...] autorelease];
    }

    // ... Set up cell ...

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)path {
    NSUInteger index = [self arrayIndexFromIndexPath:path];
    NSDictionary *data = [self.dataArray objectAtIndex:index];

    // ... Do whatever you need with the data ...
}
@interface MyTableViewCell : UITableViewCell {
    NSDictionary *data_;
}

@property (nonatomic, retain) NSDictionary *data;

@end
@implementation MyTableViewCell

@synthesize data=data_;

- (void)dealloc {
    [data_ release]; data_ = nil;
    [super dealloc];
}

@end
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)path {
    NSUInteger index = [self arrayIndexFromIndexPath:path];
    NSDictionary *data = [self.dataArray objectAtIndex:index];

    // Remember, of course, to use a different reuseIdentifier for each different kind of cell.
    MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:...];
    if (!cell) {
        cell = [[[MyTableViewCell alloc] initWithStyle:... reuseIdentifier:...] autorelease];
    }

    cell.data = data;

    // ... Set up cell ...

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)path {
    MyTableViewCell *cell = [tableView cellForRowAtIndexPath:path];
    NSDictionary *data = cell.data;

    // ... Do whatever you need with the data ...
}
How to change uitableviewcell data in different section?

How to change uitableviewcell data in different section?


By : Final Fun
Date : March 29 2020, 07:55 AM
Hope this helps You will get a nil from cellForRowAtIndexPath: if one of the cells isn't visible at the moment. You should therefore get the needed entry from your data-model, not from the UI. Change the needed information there:
code :
NSArray *section1Data = [self.dataModell objectAtIndex:section1];
NSDictionary *dataObject1 = [section1Data objectAtIndex:row1];
[dataObject1 setValue:@"My new Text." forKey:@"theTextPropertyKey"];

NSArray *section2Data = [self.dataModell objectAtIndex:section2];
NSDictionary *dataObject2 = [section1Data objectAtIndex:row2];
[dataObject2 setValue:@"My new Text." forKey:@"theTextPropertyKey"];
NSArray *indexPaths = @[indexPath1, indexPath2];
[self.tableView reloadRowsAtIndexPaths:indexPaths];
Change of data in UITableViewCell while Scrolling

Change of data in UITableViewCell while Scrolling


By : j802d
Date : March 29 2020, 07:55 AM
Hope that helps Check how currentScroe is being set in your code. Check if it gets modified elsewhere. I doubt that the currentScore in the Player object itself is 0.
iOS - UITableViewCell change height depending on data cell holds

iOS - UITableViewCell change height depending on data cell holds


By : Koren Siso
Date : March 29 2020, 07:55 AM
I wish this help you You are on the right path to do this in - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
Look in Apple's NSString UIKit Additions Reference to see how to get the size of your string:
Related Posts Related Posts :
  • Xcode 7.1 with iOS 9.2 Error (Could not find Developer Disk image)
  • What will happen by calling [super alloc] in a subclass' factory method?
  • Why there is no warning while casting with viewWithTag?
  • Can I start my iOS app on the 2nd View of My Storyboard and use the Unwind Segue?
  • How to resize a UIImageView and force relayout of the parent UITableViewCell
  • Logically determine shortest path
  • autolayout problems by code?
  • Using componentsSeparatedByString with more than one separator string?
  • iOS : application crashing for null values while displaying scrolling tableview
  • How to Programmatically Segue to a New ViewController in a New Storyboard
  • Interpolation in texture3D in OpenGL ES 3.0 on iOS
  • How do I remove new line characters from a string?
  • Grouped UITableView from array of objects
  • How to write this answer in Swift? popToRoot on one tab when the user is in a different tab?
  • Collection View Loads Choppy
  • How to trigger certain segue for a selected nib cell in didSelectRowAtIndexPath
  • Filter users based on their specified age ranges. Parse and Swift
  • Audio queue recording error: AudioConverterNew from AudioQueueNew returned 'fmt?'
  • no registered handler for URL scheme itms-apps - Rate button Simulator
  • Escaping parameters in iOS Apple App Store Download Link
  • Resizing UISearchBar in UINavigationBar titleView doesn't work
  • Button that will generate a random background color - Xcode - Swift
  • Subclassing SCNScene and SceneKit Editor
  • iOS: get result of 'currentUserNotificationSettings' alert dialog
  • Delete user in iOS using Parse login
  • iPad Pro reporting wrong screen scale
  • Solving math using DDMathParser in Objective-C
  • Why does Acknowledgements.plist from CocoaPods look messed up on iOS 9 and what can you do about it?
  • reloadRowsAtIndexPaths interfere with deleteRowsAtIndexPaths
  • How to do core data fetch predicate for NSDate in swift? i want to filter it by months
  • Creating a centered View with Labels
  • Singleton Created, Errors upon use in ViewController?
  • Error using performSegueWithIdentifier Swift 2.1
  • I've created a singleton class, how can I call it from my ViewControllers?
  • Alamofire won't build in empty Swift project using Cocoapods
  • Set first annotation in annotations
  • Swift 2.1 New Way to Initialize String Array?
  • Swift - time based UUID - how to sort them
  • Swift: How can I have a listener that reports when connection is lost and when it comes back?
  • Xcode fails to generate Adhoc IPA
  • Apple Watch - how do I schedule a complication update to be in synch with Push notification?
  • UICollectionView will not display cells in custom popupview
  • iOS: Repeat animation block until an event completes
  • Set NavigationBar for Destination ViewController Only
  • ios9 Image Download
  • Accessing Value of NSDictionary within array
  • ios9 - Xcode 7 - Swift - Keyboard shows correctly in Simulator but not on an actual Device
  • Sizing for UITabBar images?
  • Sharing a Realm Database between a user's devices
  • Use of @dynamic in objectiveC
  • PFGeoPoint to save something on map permanently?
  • Xcode Table Cell not Fully Highlighted
  • Parse crash reporting 1.9.2 not working
  • Over the air distribution stopped working XCode7.1.1
  • How to change property for multiple IBOutlet
  • How pop multiples Views of navigationBar and return an object to first page?
  • UICollectionView segue from Sign-up showing a black screen
  • UICollectionView CustomCell ReUse
  • iOS PushKit (VoIP Push Notifications) Quality of Service
  • Upgrade Fabric and Crashlytics for iOS App
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co