Why is detailTextLabel not visible? - objective-c

detailTextLabel is not visible (code below). Can you tell me why?
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
NSString *cellValue = [myListArray objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
cell.detailTextLabel.text = #"Hello "; // This is not visible
cell.image = [myListArrayImages objectAtIndex:indexPath.row];
return cell;
}

The detailTextLabel is not displayed for cells with the UITableViewCellStyleDefault style. init the UITableViewCell with UITableViewCellStyleSubtitle instead and you should see your detailTextLabel.
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];

Or if you are using Interface Builder, change the Style cell property to Subtitle. :)

In order to solve it programmatically:
let cell = UITableViewCell(style: .subtitle, reuseIdentifier: "identifier")

I have used this and it worked for me:
// programming mark ----- ----- ---- ----- ----- ---- ----- ----- ----
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let CellIdentifier: String = "CellIdentifier"
var cell = tableView.dequeueReusableCellWithIdentifier(CellIdentifier) as? UITableViewCell
if cell == nil {
cell = UITableViewCell(style: UITableViewCellStyle.Value1, reuseIdentifier: CellIdentifier)
}
cell!.textLabel!.text = "Title"
cell!.detailTextLabel!.text = "Value"
return cell!
}

Swift 5
You can enable this inside cellForRowAt method
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell = UITableViewCell(style: .subtitle, reuseIdentifier: "cell")
cell.textLabel?.text = qus[indexPath.row]
cell.detailTextLabel?.text = ans[indexPath.row]
return cell
}

I just want to mention that the wording in the UITableViewCell class reference can be a little bit confusing on this issue:
(After describing each cell type)
"Discussion
In all these cell styles, the larger of the text labels is accessed via the textLabel property and the smaller via the detailTextLabel property."
It might seem that it's saying all of the cell types include a detailTextLabel, but if you carefully read through them it's only the default type that does not have a detailTextLabel.

Related

Set text to textfield of table Cell in objective c outside UITableView delegate methods

I am new to objective C,and have made a demo app.
In this app I am having a UITableView which contains textField.When I taps a button(sign in using Facebook), after successfully login from Facebook it come back to my TableView screen,at that time i want to set values came from Facebook response to UITableView's textFields, but I am unable to do it as TableView's delegate method is calling only once.
Can anybody please help me to set text to tableView's textField outside its delegate method?
code
NSString *cellIdentifier = [[signInTableData objectAtIndex:2] objectForKey:#"cellIdentifier"];
signUpCustomCell *cell = (signUpCustomCell *)[signUpTable dequeueReusableCellWithIdentifier:cellIdentifier];
//NSLog(#"=====my username cell====%#",indexPath);
if(cell == nil)
{
cell = (signUpCustomCell *)[[signUpCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.backgroundColor = [UIColor clearColor];
cell.tableField.delegate = self;
CGRect frmTxt = cell.tableField.frame;
frmTxt.size.width = signUpTable.frame.size.width + TRAIL_MARGIN_CELL_CONTENT;
cell.tableField.frame = frmTxt;
cell.tableField.text = #"hello test";
If you know at which row your UITextField is then you can query UITableView for a cell at given IndexPath.
NSIndexPath *ip = [NSIndexPath indexPathForRow:0 inSection:0];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:ip];
You'll need to cast that cell to what ever custom cell you are using to access the UITextField inside and your custom UITableViewCell should have a property that points to the UITextField or a method that would update the text.
-(void)viewWillAppear or -(void)viewDidApper overrides in your UIViewController subclass could be the places to do that, after you have loaded your data to the UITableView.
You need to set values into UITextField in delegate
cellForRowAtIndexPath as it is rendered for every cell of UITableView.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"yourcellidentifier"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:#"yourcellidentifier"] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
cell.yourTextView.text= textforRow;
return cell;
}

UITableView Cell highlight / retain selected value IOS

I have UIView(LeftMenu) with UITableView (UITableViewStylePlain). I have around 7 controllers , Where on selection of each cell I wanna push corresponding controller. I tried custom highlight for cell with yellow color as below ,
UIColor *yel=[[UIColor alloc]initWithRed:240/255.0 green:197/255.0 blue:67/255.0 alpha:1.0];
UIView *bgColorView = [[UIView alloc] init];
[bgColorView setBackgroundColor:yel];
[cell setSelectedBackgroundView:bgColorView];
in cellForRowAtIndexPath. But I am unable to retain selected cell If I move to next controller. In didSelectRowAtIndexPath , I am capturing last selected index ( When I select new cell , old should be unhighlighted). But it seems , If I make custom its not retaining. If I keep UITableViewCellSelectionStyleNone , cell.backgroundColor it works. But not highlighting :(
[[NSUserDefaults standardUserDefaults]setInteger:indexPath.row forKey:#"SSLastSelectedLeftMenuIndex"];
I am initializing UIView(LeftMenu) with frame.
Issue : Gray Color on Highlight after few mins custom yellow highlight coming and Not retaining selected cell color.
I know I am missing some silly thing. But its eating my time. Advance thanks :)
Update:-
below is my -cellForRowAtIndexpath method
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
if([[NSUserDefaults standardUserDefaults]integerForKey:#"SSLastSelectedLeftMenuIndex"]==indexPath.ro‌w)
{
///<HIGHLIGHT CODE>;
}
to select the last selectd cell .. (try)
- (void)viewWillAppear
{
[uper viewWillAppear];
//hear u can set the selected cell
//get indexpath of row
int k = your saved row
NSIndexPAth *path = [NSIndexPath indexPathWithIndex:k];//if u hav single section or u can use other class method
[tableView selectRowAtIndexPath:_selctedIndex animated:NO scrollPosition: UITableViewScrollPositionNone];//hear u are directly setting the last selected cell once view will appear
}
hop this helps u :)
if u are using UITableViewCell then u do something like this,for yellow color for selecting the cell
//in controller do like this
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"cell"];
if(cell == nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"cell"];
UIColor *yel=[[UIColor alloc]initWithRed:240/255.0 green:197/255.0 blue:67/255.0 alpha:1.0];
UIView *bgColorView = [[UIView alloc] init];
[bgColorView setBackgroundColor:yel];
[cell setSelectedBackgroundView:bgColorView];
}
return cell;
}
in the subclassed table cell there is one method, to display yellow color for selecting the cell
//in CustomCell.m
//in the custom cell set the color for selected state
//override this method
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
if(selected)
{
//same code of urs
UIColor *yel=[[UIColor alloc]initWithRed:240/255.0 green:197/255.0 blue:67/255.0 alpha:1.0];
UIView *bgColorView = [[UIView alloc] initWithFrame:self.bounds];//for entaire cell,set the frame
[bgColorView setBackgroundColor:yel];
[self setSelectedBackgroundView:bgColorView];
}
}
You have misunderstood selection and highlighting a cell you should change your cellForRowAtIndexPath like below to select the previously selected item.
before that Declare a globle variable _selctedIndex of type NSIndexpath to store the last selected cell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
UIColor *yel=[[UIColor alloc]initWithRed:240/255.0 green:197/255.0 blue:67/255.0 alpha:1.0];
UIView *bgColorView = [[UIView alloc] init];
[bgColorView setBackgroundColor:yel];
[cell setSelectedBackgroundView:bgColorView];
}
if([[NSUserDefaults standardUserDefaults]integerForKey:#"SSLastSelectedLeftMenuIndex"]==indexPath.row)
{
//<HIGHLIGHT CODE>;
_selctedIndex=indexPath; //code Updated
}
return cell;
}
After your tableView has reloaded call the below line of code
[tableView selectRowAtIndexPath:_selctedIndex animated:NO scrollPosition:UITableViewScrollPositionTop];
}
The UITableViewCell class will assign the view you have mentioned to the property selectedBackgroundView instead of the Default blue color view for showing in the background when a cell is selected
I ran into the exact same problem in a project, when tapping on a cell long enough to engage highlight then moving to a scroll the UITableView holds onto the highlighted index somehow so that the next attempt to select uses that previous indexPath.
To resolve I did the following
Add Property to Track Offending indexPath
...
#property (nonatomic,strong) NSIndexPath *cachedPath;
...
Track indexPath with didUnhighlightRowAtIndexPath
- (void)tableView:(UITableView *)tableView didUnhighlightRowAtIndexPath:(NSIndexPath *)indexPath
{
self.cachedPath = indexPath;
}
On Drag reload offending indexPath
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
if (self.cachedPath)
{
[self.tableView reloadRowsAtIndexPaths:#[self.cachedPath] withRowAnimation:UITableViewRowAnimationNone];
}
self.cachedPath = nil;
}
For good measure clear the property on selection
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.cachedPath = nil;
}

NSTableViewCell.ImageView Setting Position?

I have a NSTableViewCell which has a ImageView within the cell.
What is needed to control the position of the image within the cell using code?
If you are using subclass of NSTextFieldCell(ImageAndTextCell). you can control positon of image in
- (NSRect)imageRectForBounds:(NSRect)cellFrame method.
You can create custom cell...
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"ImageOnRightCell";
UIImageView *photo;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
photo = [[[UIImageView alloc] initWithFrame:CGRectMake(225.0, 0.0, 80.0, 45.0)]];
photo.tag = PHOTO_TAG;
photo.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
[cell.contentView addSubview:photo];
} else {
photo = (UIImageView *)[cell.contentView viewWithTag:PHOTO_TAG];
}
return cell;
}
This will look like it....
or u can read this link....
http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/tableview_iphone/TableViewCells/TableViewCells.html
instead of default TableViewCell, create your own custom tableViewCell and position it according to your need.

didSelectRowAtIndexPath selecting more than one row at a time

I have a UITableView populated with 27 rows. I am trying to change the accessoryType of the selected cell. I do that in the didSelectRowAtIndexPath: delegate method.
The problem I am facing is that, when selecting a row and changing the accessoryType of the cell, the eleventh row from that row also gets modified.
I have tried printing the [indexPath row] value, but it's showing only the row that was selected and not another one.
I am really puzzled by such stuff; please help me out.
ADDED THE CODE cellForRowAtIndexPath method
UITableViewCell *cell;
if ([indexPath row] == 0) {
cell = [tableView dequeueReusableCellWithIdentifier:#"acell"];
}
else {
cell = [tableView dequeueReusableCellWithIdentifier:#"bcell"];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if (cell == nil && [indexPath row] != 0) {
cell = [[[UITableViewCell alloc] initWithStyle:
UITableViewCellStyleSubtitle reuseIdentifier:#"bcell"] autorelease];
}
else if(cell == nil && [indexPath row] == 0){
cell = [[[UITableViewCell alloc] initWithStyle:
UITableViewCellStyleSubtitle reuseIdentifier:#"acell"] autorelease];
}
if ([cell.contentView subviews]){
for (UIView *subview in [cell.contentView subviews]) {
[subview removeFromSuperview];
}
}
if ([indexPath row] == 0) {
cell.textLabel.text = #"Select All";
cell.textLabel.font = [UIFont boldSystemFontOfSize:13.0f];
}
else {
cell.textLabel.text = #"Some Text Here"
cell.detailTextLabel.text = #"Another piece of text here"
}
return cell;
I am doing %10 because the behaviour is repeating after 11th row, hence trying to create new object for every 11th row.
My didSelectRowAtIndexPath methos code is
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
if ([indexPath row] != 0) {
NSIndexPath *tempIndex = [NSIndexPath indexPathForRow:0 inSection:0];
UITableViewCell *tempCell = [tableView cellForRowAtIndexPath:tempIndex];
tempCell.accessoryType = UITableViewCellAccessoryNone;
}
cell.accessoryType = UITableViewCellAccessoryNone;
}
else{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
if ([indexPath row] == 0) {
for (int i = 0; i < [dataSource count]; i++) {
NSIndexPath *tempIndex = [NSIndexPath indexPathForRow:i+1 inSection:0];
UITableViewCell *tempCell = [tableView cellForRowAtIndexPath:tempIndex];
if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
tempCell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else{
tempCell.accessoryType = UITableViewCellAccessoryNone;
}
}
}
Please help me in multiple selection or anyother way to solve the problem of multiple selection.
Thanks in advance!!
Here's one way to do it:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
[cell.textLabel setText:[NSString stringWithFormat:#"Row %d", indexPath.row]];
NSIndexPath* selection = [tableView indexPathForSelectedRow];
if (selection && selection.row == indexPath.row) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
// Configure the cell.
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone;
}
Remember every cell in the table view is actually the same object being re-used. If you don't set the accessory type every time cellForRowAtIndexPath is called, when new cells scroll onto the screen they're going to all have the same accessory.
Multiple Select
For multiple selection it's a bit more complicated.
Your first option: Undocumented API
Note that this only works when the table's in editing mode. Set each cell's editing style to the undocumented UITableViewCellEditingStyleMultiSelect. Once you do that, you can get the table view's selection via an undocumented member of UITableView: indexPathsForSelectedRows. That should return an array of the selected cells.
You can expose this bit of functionality by putting this in a header:
enum {
UITableViewCellEditingStyleMultiSelect = 3,
};
#interface UITableView (undocumented)
- (NSArray *)indexPathsForSelectedRows;
#end
Then set the editing style for each cell like so:
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleMultiSelect;
}
When the table is in editing mode you'll see the multi-select controls on your cells.
To look through other undocumented API, you can use the nm command line utility like this:
nm /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System/Library/Frameworks/UIKit.framework/UIKit
Your second option: Manage the selection yourself
Have your UITableView subclass contain an array that indicates which cells are selected. Then in cellForRowAtIndexPath, configure the cell's appearance using that array. Your didSelectRowAtIndexPath method should then look something like this:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([tableView indexPathIsSelected:indexPath]) {
[tableView removeIndexPathFromSelection:indexPath];
} else {
[tableView addIndexPathToSelection:indexPath];
}
// Update the cell's appearance somewhere here
[tableView deselectRowAtIndexPath:indexPath animated:NO];
}
This assumes you create indexPathIsSelected, removeIndexPathFromSelection, and addIndexPathToSelection methods in your UITableView subclass. These methods should do exactly what their names imply: Add, remove, and check for index paths in an array. You wouldn't need a didDeselectRowAtIndexPath implementation if you go with this option.
Remember every cell in the table view is actually the same object being re-used. If you don't set the accessory type every time cellForRowAtIndexPath is called, when new cells scroll onto the screen they're going to all have the same accessory." - daxnitro
This is where I got caught. I had mine set up so that in my "cellForRowAtIndexPath" function, I would only change the accessory for those specified in my array of checked cells, when what I should have done was update the accessory for all cells in the table.
In other words:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//normal set up
//retrieve key
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults];
id obj = [settings objectForKey:#yourKey];
//if the array is not populated, keep standard format for all cells
if (obj == nil){
selectedStyles = [[NSMutableArray alloc] initWithObjects:nil];
[cell setAccessoryType:UITableViewCellAccessoryNone]; //no check mark
[cell textLabel].textColor = [[UIColor alloc] initWithRed:0.0/255 green:0.0/255 blue:0.0/255 alpha:1.0]; //keep black color
}
//else retrieve information from the array and update the cell's accessory
else{
//if the cell is in your array, add a checkbox
[cell setAccessoryType:UITableViewCellAccessoryCheckmark]; //add check box
[cell textLabel].textColor = [[UIColor alloc] initWithRed:50.0/255 green:79.0/255 blue:133.0/255 alpha:1.0]; //change color of text label
//if the cell is not in your array, then keep standard format
[cell setAccessoryType:UITableViewCellAccessoryNone]; //no check mark
[cell textLabel].textColor = [[UIColor alloc] initWithRed:0.0/255 green:0.0/255 blue:0.0/255 alpha:1.0]; //keep black color
Hope this helps!

UITableViewCell checkmark change on select

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;
}