¿Alguien me puede ayudar a hacer que UIView creado en código esté en la parte superior de todas las otras vistas? donde tableView es la vista principal y subSelectionView es mi vista de hermanos personalizada, quiero hacerlo sobre tableView. Tengo este código a continuación:Coloque UIView en la parte superior de todas las demás vistas
Este es el código fuente completo de mi didSelectRowAtIndexPath :, desde donde yo programación añadir instancia 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];
}
pero no funciona ..
la imagen de abajo muestra mi subSelectionView, el botón está dentro de ella y la subSelectionView está dentro del tableView. Ahora, cuando hice clic en ese botón, el problema es que no puedo hacer clic en él. Se enfoca directamente en tableView incluso con la presencia de mis códigos. Alguien me puede ayudar por favor? ....
Gracias pete ... Ya lo había revisado y configuré la propiedad de habilitar el botón en sí, pero todavía no funciona ... hmmm ... ¿estoy en lo cierto al usar este código: [[tableView cellForRowAtIndexPath: indexPath] insertSubview: subSelectionView aboveSubview: self.view ];? – Aldee
Si puede ver la subvista, entonces sí, el problema es que no recibe eventos. –