From 11f10b583cef983340f3cd2d338614593a6401e9 Mon Sep 17 00:00:00 2001 From: Gabriel Cavalcante Date: Wed, 20 Apr 2016 11:58:59 -0300 Subject: [PATCH] AlertView Color --- ColorPalettes/ColorPalettes/ViewController.m | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ColorPalettes/ColorPalettes/ViewController.m b/ColorPalettes/ColorPalettes/ViewController.m index 78a21a2..bab20b6 100644 --- a/ColorPalettes/ColorPalettes/ViewController.m +++ b/ColorPalettes/ColorPalettes/ViewController.m @@ -14,7 +14,7 @@ blue:((float)((rgbValue & 0x0000FF) >> 0))/255.0 \ alpha:1.0] -@interface ViewController () +@interface ViewController () @property (nonatomic, strong) NSArray *colors; @@ -49,6 +49,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N // TODO: Adicionar o método tableView:didSelectRowAtIndexPath: // TODO: Ao tocar em uma cor exibir o Hex dessa cor em um alerta. +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ + [self alert:@"Cor" setMensagem:[[NSString alloc] initWithFormat:@"%@",[self.colors objectAtIndex:indexPath.row]]]; +} + #pragma mark - Button Actions Methods - (void)changePallete:(UIBarButtonItem *)sender { @@ -70,4 +74,10 @@ - (void)didReceiveMemoryWarning { // Dispose of any resources that can be recreated. } +-(void)alert: (NSString*)titulo setMensagem:(NSString*)mensagem{ + UIAlertView *alert = [[UIAlertView alloc] initWithTitle:titulo message:mensagem delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; + + [alert show]; +} + @end