How do you change the font color of a "focused" UITableView cell? I currently have this....
- (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator {
if (context.nextFocusedView) {
CategoryCell *cell = [self.categoryTableView dequeueReusableCellWithIdentifier:#"CategoryCell"];
[cell.categoryLbl setTextColor:[UIColor orangeColor]];
}
}
I know that if you want to change a background of a focused UITableViewCell it would be:
- (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator {
[context.nextFocusedView setBackgroundColor:[UIColor clearColor]];
[context.previouslyFocusedView setBackgroundColor:[UIColor orangeColor]];
}
In TVOS UITableViewDelegate have new method tableView:didUpdateFocusInContext:withAnimationCoordinator: which will be called when focus change, you can get previous IndexPath and nextFocusIndexPath and then you can use tableView methods to get cells, your code should look like this
- (void)tableView:(UITableView *)tableView didUpdateFocusInContext:(UITableViewFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator
{
NSIndexPath *prevIndexPath = [context previouslyFocusedIndexPath];
if (prevIndexPath)
{
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:prevIndexPath];
cell.textLabel.textColor = [UIColor white];
}
NSIndexPath *nextIndexPath = [context nextFocusedIndexPath];
if (nextIndexPath)
{
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:nextIndexPath];
cell.textLabel.textColor = [UIColor blackColor];
}
}
Please visit this Apple docs for more detail
Here is my approach using Swift 2.0 :)
func tableView(tableView: UITableView, didUpdateFocusInContext context: UITableViewFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
if let prevIndexPath = context.previouslyFocusedIndexPath {
let prevCell = tableView.cellForRowAtIndexPath(prevIndexPath)
prevCell?.backgroundColor = UIColor.blackColor()
}
if let nextIndexPath = context.nextFocusedIndexPath {
let nextCell = tableView.cellForRowAtIndexPath(nextIndexPath)
nextCell?.backgroundColor = UIColor.whiteColor()
}
}
Here's a good solution in swift 2.0.
func tableView(tableView: UITableView, didUpdateFocusInContext context: UITableViewFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
if ((context.previouslyFocusedIndexPath) != nil) {
let cell = tableView.cellForRowAtIndexPath(context.previouslyFocusedIndexPath!)
cell?.textLabel?.textColor = UIColor.whiteColor()
}
if ((context.nextFocusedIndexPath) != nil) {
let cell = tableView.cellForRowAtIndexPath(context.nextFocusedIndexPath!)
cell?.textLabel?.textColor = UIColor.blackColor()
}
}
Here is what you want to achieve in Swift 5.2:
func tableView(_ tableView: UITableView, didUpdateFocusIn context: UITableViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {
if let prevIndexPath = context.previouslyFocusedIndexPath {
let prevCell = tableView.cellForRow(at: prevIndexPath) as! TVHomeCell
prevCell.titleLabel.font = .systemFont(ofSize: 32, weight: .medium)
}
if let nextIndexPath = context.nextFocusedIndexPath {
let nextCell = tableView.cellForRow(at: nextIndexPath) as! TVHomeCell
nextCell.titleLabel.font = .systemFont(ofSize: 34, weight: .bold)
}
}
You can change colour by using context , it contain reference of previously focused cell and the current cell that is focused. just cast it to your cell type and then perform the colour change operation.
override func didUpdateFocus(in context: UIFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {
if let prevIndex = context.previouslyFocusedItem{
if let myCell = prevIndex as? Mycell {
myCell.textLabel.textColor = UIColor.white
}
}
if let nextIndex = context.nextFocusedItem {
if let myCell = nextIndex as? MyCell {
myCell.textLabel.textColor = UIColor.black
}
}
}
Related
I have two views. In class one I have table with custom cell, where am re-using the cell for three times. I wanted to update table cell text of each row with selected text from another class. I have implemented protocol to take the text value from another class and updating. For storing each row value am using NSDictionary. So that I can take the dictionary value and update in my cellforrowatindexpath to update cell text value. My code,
Class A - Objective C :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = #"challengeTableCell";
cell = (EnrollmentChallengeTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[EnrollmentChallengeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.answerTextfield.delegate = self;
if (indexPath.row == 0) {
cell.questionTitleLabel.text = #"Challenge Question 1";
cell.questionLabel.tag = 100;
cell.questionLabel.textColor = [UIColor blackColor];
NSString *user1 = [myDict objectForKey:#"firstQuestion"];
NSLog(#"firstquestion: %#",user1);
}
else if (indexPath.row == 1) {
cell.questionTitleLabel.text = #"Challenge Question 2";
cell.questionLabel.tag = 101;
NSString *user2 = [myDict objectForKey:#"secondQuestion"];
NSLog(#"secondQuestion: %#",user2);
}
else {
cell.questionTitleLabel.text = #"Challenge Question 3";
cell.questionLabel.tag = 102;
NSString *user3 = [myDict objectForKey:#"thirdQuestion"];
NSLog(#"thirdQuestion: %#",user3);
}
if (cell.questionLabel.tag == 100 || cell.questionLabel.tag == 101 || cell.questionLabel.tag == 102) {
UITapGestureRecognizer* gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(selectQuestion:)];
[cell.questionLabel setUserInteractionEnabled:YES];
[cell.questionLabel addGestureRecognizer:gesture];
}
return cell;
}
-(void)selectQuestion:(UITapGestureRecognizer *) sender
{
CGPoint touchLocation = [sender locationOfTouch:0 inView:challengeQuestionsTable];
newIndexPath = [challengeQuestionsTable indexPathForRowAtPoint:touchLocation];
selectQuestionVC = [EnrollmentSelectQuestionViewController instantiate];
selectQuestionVC.questionDelegate = self;
[self presentViewController:selectQuestionVC animated:YES completion:nil];
}
#pragma mark - Table Selection Delegate
-(void)valueChanged:(NSString *)questionString {
//[challengeQuestionsTable reloadRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationNone];
passedValue = questionString;
NSLog(#"questionvalue: %#",passedValue);
NSLog(#"mydict: %lu",(unsigned long)[myDict count]);
cell = [challengeQuestionsTable cellForRowAtIndexPath:newIndexPath];
NSLog(#"you have selected index: %ld", (long)newIndexPath.row);
[[NSUserDefaults standardUserDefaults] setInteger:newIndexPath.row forKey:#"SelectedIndex"];
[[NSUserDefaults standardUserDefaults] synchronize];
// NSInteger numberOfRows = [challengeQuestionsTable numberOfRowsInSection:[indexPath section]];
NSLog(#"indexpath row: %ld",newIndexPath.row);
if (newIndexPath.row == 0) {
[myDict setValue:passedValue forKey:#"firstQuestion"];
} else if (newIndexPath.row == 1) {
[myDict setValue:passedValue forKey:#"secondQuestion"];
} else {
[myDict setValue:passedValue forKey:#"thirdQuestion"];
}
NSLog(#"mydict: %#",myDict);
NSLog(#"1st: %#",[myDict objectForKey:#"firstQuestion"]);
NSLog(#"2nd: %#",[myDict objectForKey:#"secondQuestion"]);
NSLog(#"3rd: %#",[myDict objectForKey:#"thirdQuestion"]);
}
Class B - Swift:
var questionDelegate: SelectedQuestionDelegate?
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
print("selected index :",indexPath.row)
let selectedCell = tableView.cellForRow(at: indexPath)
print("did select and the text is \(selectedCell?.textLabel?.text)")
let storyboard = UIStoryboard(name: "EnrollmentChallengeQuestions", bundle: nil)
challengeVC = storyboard.instantiateViewController(withIdentifier: "ChallengeQuestions") as! EnrollmentChallengeQuestionsViewController
challengeVC.passedValue = selectedCell?.textLabel?.text
print("text label value: ", challengeVC.passedValue)
questionDelegate?.valueChanged(challengeVC.passedValue)
self.present(challengeVC, animated: true , completion: nil)
}
Here in ValueChanged function, My dictionary is holding only one value at a time. I want to hold the first question for first row, second question for second row and for third also simultaneously. My dictionary is getting refreshed each time. Also tried to alloc my dict in viewdidload & viewwillappear. All methods getting called again while coming from another class. How to overcome this issue?
I think you need to use dismiss(animated: true, completion: nil) instead of self.present(challengeVC, animated: true , completion: nil).
Currently when you select a question , you present the challengeVC, again so its viewDidLoad and viewWillAppear methods are being called again, hence your dictionary is being allocated again
Default focus color of UITableViewCell is white colour.
How can we change the focus colour of UITableView cell?
You can set this as in the code below:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// ...
cell.focusStyle = UITableViewCellFocusStyleCustom;
// ...
return cell;
}
- (void)tableView:(UITableView *)tableView didUpdateFocusInContext:(UITableViewFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator
{
if ([context.previouslyFocusedView isKindOfClass:[UITableViewCell class]])
context.previouslyFocusedView.backgroundColor = [UIColor clearColor];
if ([context.nextFocusedView isKindOfClass:[UITableViewCell class]])
context.nextFocusedView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3];
}
It is a swift code. Please convert to Objective-C and try it. It maybe help you.
override func didUpdateFocusInContext(context: UIFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
if let nextFoc = context.nextFocusedView as? YourCellName{
nextFoc.backgroundColor = UIColor.redColor()
}
if let prevFocus = context.previouslyFocusedView as? YourCellName{
prevFocus.backgroundColor = UIColor.clearColor()
}
Look it a screen shot.
If you want to maintain the fancy parallax cells you can first set a background view on your custom cell:
self.backgroundView = UIView()
And in your viewcontroller with the tableview do something like this:
func tableView(tableView: UITableView, didUpdateFocusInContext context: UITableViewFocusUpdateContext, withAnimationCoordinator coordinator: UIFocusAnimationCoordinator) {
(context.nextFocusedView as! MyCustomTableviewCell).backgroundView!.backgroundColor = UIColor.purpleColor()
if let prev = context.previouslyFocusedView as? MyCustomTableviewCell {
// Set the color back to whatever it was, in this case I have a black background with black cells
prev.backgroundView?.backgroundColor = UIColor.blackColor()
}
}
If you are using custom tableViewCell, then you can use the delegate method of the tableViewCell as below,
- (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator
{
if (self.focused)
{
[self showHighlightedCellStyle];//set highlighted bg color
}
else
{
[self showNormalCellStyle];//reset the bg color
}
}
Im trying to load my annotations using JPSThumbnail on swift. With the code below for some reason whenever It loads, it loads my annotations with the usual red pin. I have no clue in objective C so I dont know what should be done? What is missing in my code, am I appending right to the array?
JPSThumnail Github
JPSThumbnailAnnotation:
+ (instancetype)annotationWithThumbnail:(JPSThumbnail *)thumbnail {
return [[self alloc] initWithThumbnail:thumbnail];
}
- (id)initWithThumbnail:(JPSThumbnail *)thumbnail {
self = [super init];
if (self) {
_coordinate = thumbnail.coordinate;
_thumbnail = thumbnail;
}
return self;
}
- (MKAnnotationView *)annotationViewInMap:(MKMapView *)mapView {
if (!self.view) {
self.view = (JPSThumbnailAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:kJPSThumbnailAnnotationViewReuseID];
if (!self.view) self.view = [[JPSThumbnailAnnotationView alloc] initWithAnnotation:self];
} else {
self.view.annotation = self;
}
[self updateThumbnail:self.thumbnail animated:NO];
return self.view;
}
- (void)updateThumbnail:(JPSThumbnail *)thumbnail animated:(BOOL)animated {
if (animated) {
[UIView animateWithDuration:0.33f animations:^{
_coordinate = thumbnail.coordinate; // use ivar to avoid triggering setter
}];
} else {
_coordinate = thumbnail.coordinate; // use ivar to avoid triggering setter
}
[self.view updateWithThumbnail:thumbnail];
}
My Swift Code:
func annotations() -> [JPSThumbnailAnnotation] {
var annotations: [JPSThumbnailAnnotation] = []
let pointData = NSData(contentsOfFile: NSBundle.mainBundle().pathForResource("1000", ofType: "geojson")!)
let points = NSJSONSerialization.JSONObjectWithData(pointData!,
options: nil,
error: nil) as! NSDictionary
for point in points["glimps"] as! NSArray {
var a = JPSThumbnail()
a.image = UIImage(named: "empire.jpg")
a.title = "Empire State Building"
a.subtitle = "NYC Landmark"
var lat = (point as! NSDictionary)["latitude"] as! CLLocationDegrees
var lon = (point as! NSDictionary)["longitude"] as! CLLocationDegrees
a.coordinate = CLLocationCoordinate2DMake(lat, lon)
a.disclosureBlock = { println("selected Empire") }
var a1: JPSThumbnailAnnotation = JPSThumbnailAnnotation(thumbnail: a)
annotations.append(a1)
}
return annotations
}
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
return (annotation as? JPSThumbnailAnnotationProtocol)?.annotationViewInMap(mapView)
}
I am writing an app in XCode6. Currently I have "SelectionTableViewController.h" and "SelectionTableViewController.m" such that you could add/remove checkmarks on select. Also, I have a table view controller segue in the storyboard, that is triggered by a static cell in the previous table view controller. I set up the trigger in storyboard so I did not write the code for "prepare for segue" or anything.
I want the cell to be checked by default, so I have done the following:
Changed the view controller to "SelectionTableViewController"
Set the identifier of prototype cell on my storyboard to "SelectionCell"
Changed the cell's background color to orange and accessory to checkmark
Below is my SelectionTableViewController.m:
#implementation SelectionTableViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self.tableView registerClass:[UITableViewCell class]
forCellReuseIdentifier:#"SelectionCell"];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO];
self.navigationItem.title = #"Select";
[self.tableView reloadData];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return [[[MyStore sharedStore] allCategories] count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
NSString *category = [[[MyStore sharedStore] allCategories] objectAtIndex:section];
return [[[MyStore sharedStore] allNamesForCategory: category] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath(NSIndexPath*)indexPath
{
UITableViewCell *cell=[tableViewdequeueReusableCellWithIdentifier:#"SelectionCell"forIndexPath:indexPath];
// Configure the cell...
NSString *category = [[[MyStore sharedStore] allCategories] objectAtIndex:indexPath.section];
NSArray *items = [[MyStore sharedStore] allNamesForCategory: category];
cell.textLabel.text = [items objectAtIndex:indexPath.row];
return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
cell.accessoryType = UITableViewCellAccessoryNone;
} else {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [[[MyStore sharedStore] allCategories] objectAtIndex:section];
}
#end
My program runs on the simulator, and the items listed in the cells are correct. However the cells does not have the default checkmark on the cell before I do a selection. Nor are the cells orange. I know I can set up the default checkmark and the background color in code easily, but I just want to figure out how to do this in the interface builder, as I would be dealing with the UI a lot when the program is set up.
Hope someone can help me on that as I'm kinda new to iOS programming and this is the first time I have ever used Storyboard. Thanks!
The problem with your implementation is tableView:didSelectRowAtIndexPath will only be triggered by user's interaction only, therefore the initial selection doesn't show. You will need to make tableView aware of the selection state during initialisation too, else de-selection will not function as expected.
class ViewController: UITableViewController {
var selectedItem: Int = 5
func updateSelection(selected: Bool, forCell cell: UITableViewCell) {
cell.accessoryType = selected ? .Checkmark : .None
// update other cell appearances here..
}
override func viewDidLoad() {
super.viewDidLoad()
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
// Note: happens after the initial tableView.reloadData()
// Let tableView know who's selected before we appear, so that tableView is aware of the selection state.
// Doing so will enable tableView to know which cell to deselect after a new selection.
tableView.selectRowAtIndexPath(NSIndexPath(forItem: selectedItem, inSection: 0), animated: true, scrollPosition: .Middle)
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell") as UITableViewCell
cell.textLabel?.text = "Item \(indexPath.item)"
// Setup the selection appearance during cell creation
updateSelection(indexPath.item == selectedItem, forCell: cell)
return cell
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
// Keep track of the selection, and update cell appearance
selectedItem = indexPath.item
updateSelection(true, forCell: tableView.cellForRowAtIndexPath(indexPath)!)
}
override func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
// As above
updateSelection(false, forCell: tableView.cellForRowAtIndexPath(indexPath)!)
}
}
I've figured it out myself! I deleted the code that registered "Selection Cell". Then I did some minor changes to the cellForRowAtIndexPath
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath(NSIndexPath*)indexPath
{
Static NSString *selectionCell = #"SelectionCell";
UITableViewCell *cell=[tableViewdequeueReusableCellWithIdentifier:selectionCell forIndexPath:indexPath];
// Omit...
}
Am I correct in thinking that to change the checkmark for "on" to "off", I must change the CellAccessoryType between none and checkmark on the didSelectRowAtIndexPath?
Because I have done this but I have noticed the behaviour is not perfectly identical to like the checkmark cells on the auto lock settings on the iphone.
Or is there some other way checkmarks are meant to be handled?
Keep a property in your view controller called selectedRow, which represents the index of a row that represents the checked item in a table section.
In your view controller's -tableView:cellForRowAtIndexPath: delegate method, set the accessoryType of the cell to UITableViewCellAccessoryCheckmark if the cell's indexPath.row equals the selectedRow value. Otherwise, set it to UITableViewCellAccessoryNone.
In your view controller's -tableView:didSelectRowAtIndexPath: delegate method, set the selectedRow value to the indexPath.row that is selected, e.g.: self.selectedRow = indexPath.row
Another solution:
-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSIndexPath *oldIndex = [self.tableView indexPathForSelectedRow];
[self.tableView cellForRowAtIndexPath:oldIndex].accessoryType = UITableViewCellAccessoryNone;
[self.tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
return indexPath;
}
And yeah: you don't have to check if oldIndex is nil :)
Swift 3 and later:
override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
if let oldIndex = tableView.indexPathForSelectedRow {
tableView.cellForRow(at: oldIndex)?.accessoryType = .none
}
tableView.cellForRow(at: indexPath)?.accessoryType = .checkmark
return indexPath
}
swift:
var selectedCell:UITableViewCell?{
willSet{
selectedCell?.accessoryType = .None
newValue?.accessoryType = .Checkmark
}
}
then:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
selectedCell = self.tableView.cellForRowAtIndexPath(indexPath)
self.mapView.selectAnnotation(self.mapView.annotations[indexPath.row], animated: true)
}
Zyphrax suggested a great solution that worked great for me! And if you need to clear the previous selected row, just use:
[self.tableView reloadData];
in
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
For swift
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.cellForRow(at: indexPath)?.accessoryType = .checkmark
}
func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
tableView.cellForRow(at: indexPath)?.accessoryType = .none
}
It should be
didHighlightRowAtIndexPath
instead of
tableView:didSelectRowAtIndexPath
Alex answer worked for me only after adding reload table ,
in .h
{
int selectedCell;
}
#property(nonatomic,readwrite)int selectedCell;
in .m
*cellForRowAtIndexPath*
if(indexPath.row == selectedCell)
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
cell.selected = YES;
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
cell.selected = NO;
}
and in anywhere didHighlightRowAtIndexPath or didSelectRowAtIndexPath
self.selectedCell = indexPath.row;
[self.tableView reloadData];
If you want to use your custom image as accessoryType use below code
-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIImageView *imgCheckMark = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"select_icon.png"]];
[imgCheckMark setFrame:CGRectMake(self.view.frame.size.width - 30, 25, 14, 18)];
imgCheckMark.tag = 1000+indexPath.row;
NSIndexPath *oldIndex = [self.tblSelectService indexPathForSelectedRow];
[self.tblSelectService cellForRowAtIndexPath:oldIndex].accessoryView = UITableViewCellAccessoryNone;
[self.tblSelectService cellForRowAtIndexPath:indexPath].accessoryView = imgCheckMark;
return indexPath;
}