Qualcuno può aiutarmi su come rendere UIView creato in codice per essere in cima a tutte le altre viste? dove tableView è la vista genitore e il subSelectionView è la mia vista personalizzata fratelli, voglio farlo sopra la tabellaView .. Ho questo codice qui sotto:Posiziona UIView in cima a tutte le altre viste
Questo è il codice sorgente completo per il mio didSelectRowAtIndexPath :, da dove io aggiungo programmazione esempio UIView ..
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Execute upon selection
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[[tableView viewWithTag:199]removeFromSuperview];
// Get the cell size
CGSize cellSize = [tableView cellForRowAtIndexPath:indexPath].frame.size;
// Contact Details Container
UIView *subSelectionView;
if(indexPath.row < [contacts count] - 6)
subSelectionView = [[UIView alloc]initWithFrame:CGRectMake(10, 0, (int)cellSize.width - 20, (int)cellSize.height + 130)];
subSelectionView.backgroundColor = [UIColor grayColor];
subSelectionView.layer.borderColor = [UIColor grayColor].CGColor;
subSelectionView.layer.borderWidth = 1;
subSelectionView.alpha = 0.9;
subSelectionView.tag = 199;
subSelectionView.layer.cornerRadius = 5.0;
// Contact Name Container
UIView *contactNameSubSelectionView;
if(indexPath.row < [contacts count] - 6)
contactNameSubSelectionView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, (int)cellSize.width - 20, (int)cellSize.height)];
contactNameSubSelectionView.backgroundColor = [UIColor grayColor];
contactNameSubSelectionView.alpha = 0.5;
[subSelectionView addSubview:contactNameSubSelectionView];
// Contact Name Label
Contacts *contact = [self.contacts objectAtIndex:indexPath.row];
NSString *contactName = [NSString stringWithFormat:@" %@ %@ ", contact.fname, contact.lname];
UILabel *contactNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, (int)cellSize.width, (int)cellSize.height)];
contactNameLabel.layer.cornerRadius = 4.0;
[contactNameLabel setText: contactName];
[contactNameLabel setTextColor:[UIColor blackColor]];
[contactNameLabel setFont:[UIFont boldSystemFontOfSize:[UIFont systemFontSize]]];
[contactNameSubSelectionView addSubview:(UIView *)contactNameLabel];
// Buttons
UIButton *buttonMobile = [[UIButton alloc]initWithFrame:CGRectMake(10, cellSize.height + 10, 30, 30)];
buttonMobile.layer.borderWidth = 1;
[buttonMobile setTitle:@"..." forState:UIControlStateNormal];
[buttonMobile addTarget:self action:@selector(btPressed:) forControlEvents:UIControlStateNormal];
[subSelectionView addSubview:(UIView *) buttonMobile];
[[tableView cellForRowAtIndexPath:indexPath]insertSubview:subSelectionView aboveSubview:self.view];
[self.parentViewController.view bringSubviewToFront:subSelectionView];
[tableView reloadData];
}
ma non funziona ..
l'immagine sotto mostra la mia subSelectionView, il pulsante è all'interno di esso e la subSelectionView è all'interno del tableView. Ora, quando ho cliccato su quel pulsante, il problema è che non posso realmente cliccarlo. Si concentra direttamente sul TableView anche con la presenza dei miei codici. Qualcuno può aiutarmi per favore? ....
Grazie pete .. L'avevo già recensito e ho impostato la proprietà abilitata per il pulsante su yes ma non funziona .. hmmm .. ho ragione usando questo codice: [[tableView cellForRowAtIndexPath: indexPath] insertSubview: subSelectionView aboveSubview: self.view ] ;? – Aldee
Se è possibile vedere la sottoview, allora sì - il problema è che non riceve eventi. –