in my ios app,
i want to know indexPath for UITableViewCell
which is checkmarked?
basically i am trying to limit friend selection to 3 friends for that i disabled userinteraction for tableview if selection count is greater than 3. now i want to enable it again if selected row is equal to row which is checkmarked, so that user can replace the friend with another friend by unchecking any one of the current checkmarked row. i tried this :-
#pragma mark Limiting number of friends selected to 3
- (void)friendPickerViewControllerSelectionDidChange:
(FBFriendPickerViewController *)friendPicker
{
if ([friendPicker.selection count] <=3)
{
self.friendPickerController.tableView.userInteractionEnabled=YES;
}
if ([friendPicker.selection count] >=3)
{
UIAlertView *maxFriendsAlert =
[[UIAlertView alloc] initWithTitle:@"Max number of friends selected."
message:@"no more friends can be selected,"
delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:@"Buy more friends",nil];
[maxFriendsAlert show];
maxFriendsAlert.tag=1;
#pragma mark disable friends selection
self.friendPickerController.tableView.userInteractionEnabled=NO;
}
//enable friend selection if selected row is equal to checkmarked row i.e. enable selection for previously checkmarked row
NSIndexPath *oldindexPath1=[self.friendPickerController.selection objectAtIndex:0];
NSIndexPath *oldindexPath2=[self.friendPickerController.selection objectAtIndex:1];
NSIndexPath *oldindexPath3=[self.friendPickerController.selection objectAtIndex:2];
if (self.friendPickerController.tableView.indexPathForSelectedRow==oldindexPath1||self.friendPickerController.tableView.indexPathForSelectedRow==oldindexPath2||self.friendPickerController.tableView.indexPathForSelectedRow==oldindexPath3)
{
self.friendPickerController.tableView.userInteractionEnabled=YES;
}
}
problem is i cant know indexpath for uitableviewcell which is already checkmarked
EDIT: Aha, now I understand your issue.
Maybe this will work:
- (void)friendPickerViewControllerSelectionDidChange:(FBFriendPickerViewController *)friendPicker {
UITableView *friendPickerTable = friendPicker.tableView;
NSArray *indexPathsForSelectedRows = friendPickerTable.indexPathsForSelectedRows;
NSIndexPath *indexPathForSelectedRow = friendPickerTable.indexPathForSelectedRow;
if([indexPathsForSelectedRows containsObject:indexPathForSelectedRow]) {
// Checked friend has previously been checked
friendPickerTable.userInteractionEnabled = YES;
} else {
// New checkmark
NSUInteger checkCount = indexPathsForSelectedRows.count;
if (checkCount > 3) {
// Alert the user
UIAlertView *alert = ...
friendPickerTable.userInteractionEnabled = NO;
} else {
friendPickerTable.userInteractionEnabled = YES;
}
}
}