, , .
, , :
- , . - - . , . , , , . .
, :
:

:

, , , .
Objective-C
:
, - UITableViewCell
. ContactTableViewCell
.
ContactTableViewCell.h
:
@protocol ContactCellDelegate <NSObject>
@required
-(void) didMoveSliderWithValue:(float) value;
@end
@interface ContactTableViewCell : UITableViewCell
@property (weak, nonatomic) id<ContactCellDelegate> delegate;
TableViewController . VC MyTableViewController
.
MyTableViewController.h
:
@interface MyTableViewController : UIViewController <ContactCellDelegate>
cellForRowAtIndexPath
:
cell.delegate = self;
MyTableViewController.m
.
-(void) didMoveSliderWithValue: (float) value
{
NSLog(@"Value is : %f",value);
}
ContactTableViewCell.m
. IBAction . , :
- (IBAction)sliderValueChanged:(UISlider *)sender {
self.myTextLabel.text = [@((int)sender.value) stringValue];
[delegate didMoveSliderWithValue:sender.value];
}
, , MyTableViewController
. , .
, , VC ( Cell), ", , . ", VC , , .
Swift
:
, TableViewCell.swift
, :
@class_protocol protocol ContactCellDelegate {
func didMoveSliderWithValue(value: Float)
}
Cell , :
var cellDelegate: ContactCellDelegate?
IBAction :
self.cellDelegate?.didMoveSliderWithValue(slider.value)
VC :
:
class MyTableViewController: UIViewController, ContactCellDelegate
cellForRowAtIndexPath
cell.cellDelegate = self
:
func didMoveSliderWithValue(value:float) {
}
Swift , Obj-C Swift. , .
.: fooobar.com/questions/5343/...