I have been looking until 6 o'clock this morning, but I can't figure out why the didSelectRowAtIndexPath method is not being called. I am getting quite desparate on this one.
The tableview is shown properly, but I cannot succeed to enable the selection of a cell.
In the header file , I added:
In the implementation file:
The delegate and datasource are both not nil on the check.
Note that the "Alertstable" inherits from a UIViewController, not a UITableViewController.
This is necessary due to the implementation I chose: the tableview is shown on a popupwindow shown on the screen (using another class that I took from the internet).
This is the didSelectRowAtIndexPath method:
The methods:
are not implemented.
I added the AlertTable from another ViewController
I also implemented:
Do you have any idea what the problem could be?
I'm really stuck.
The link to the project is https://www.bilbu.be/BarConnect_v2.zip
The LoginViewController.xib is not properly linked so you may need to do that (I noticed too late).
ViewController VC class calls the AlertsTable VC class.
There is more in the project that I suppose you can ignore...
Note that the purpose of this project is only to serve as interface prototype.
The tableview is shown properly, but I cannot succeed to enable the selection of a cell.
In the header file , I added:
Code:
@interface AlertsTable : UIViewController<UITableViewDelegate, UITableViewDataSource, CMPopTipViewDelegate>{ UITableView *TableView; }
@property (nonatomic, retain) UITableView *TableView;
In the implementation file:
Code:
@synthesize TableView;
- (void)viewDidLoad {
[super viewDidLoad];
CGFloat sideMargin = 10;
CGFloat topBottomMargin = 44;
CGFloat originX = sideMargin;
CGFloat sizeWidth = (self.view.bounds.size.width - (sideMargin * 2));
CGFloat originY = topBottomMargin;
CGFloat sizeHeight = (self.view.bounds.size.height - (topBottomMargin * 2));
self.TableView = [[UITableView alloc] initWithFrame:CGRectMake(originX, originY, sizeWidth, sizeHeight) style:UITableViewStylePlain];
//Initialize the array.
AlertsItems = [[NSMutableArray alloc] initWithObjects: @"Alert 1", @"Alert 2", @"Alert 3" , @"Alert 4", @"Alert 5", @"Alert 6", nil];
[self.TableView setDelegate:self];
[self.TableView setDataSource:self];
[self.view addSubview:TableView];
TableView.userInteractionEnabled = YES;
TableView.allowsSelection = YES;
TableView.allowsSelectionDuringEditing = YES; NSLog(@"delegate:%@ dataSource:%@", self.TableView.delegate, self.TableView.dataSource);
}
The delegate and datasource are both not nil on the check.
Note that the "Alertstable" inherits from a UIViewController, not a UITableViewController.
This is necessary due to the implementation I chose: the tableview is shown on a popupwindow shown on the screen (using another class that I took from the internet).
This is the didSelectRowAtIndexPath method:
Code:
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *alertString = [NSString stringWithFormat:@"Clicked on row #%d", [indexPath row]];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:alertString message:@"" delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil];
[alert show];
}
The methods:
Code:
[super touchesBegan:...];
[super touchesEnded:...];
[super touchesMoved:...];
are not implemented.
I added the AlertTable from another ViewController
Code:
AlertsTable *AlertTable = [[AlertsTable alloc] WithButton:sender withArray:self.PopTipViews];
[self.view addSubview:AlertTable.view];
I also implemented:
Code:
- (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];
}
// Set up the cell...
[[cell textLabel] setText:[AlertsItems objectAtIndex:indexPath.row]]; NSLog (@"%@",[AlertsItems objectAtIndex:indexPath.row]);
return cell; }
Do you have any idea what the problem could be?
I'm really stuck.
The link to the project is https://www.bilbu.be/BarConnect_v2.zip
The LoginViewController.xib is not properly linked so you may need to do that (I noticed too late).
ViewController VC class calls the AlertsTable VC class.
There is more in the project that I suppose you can ignore...
Note that the purpose of this project is only to serve as interface prototype.