Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 赞成“]; [\u transportDataArray addObject:transportData]; transportData=[[TransportAlloc]init]; transportData.name=@“商队”; transportData.transportImage=[UIImage ImageName:@“Caravan”]; transportData.usedTransportImage=[UIImage imageNamed:@“stamp grayed”]; [\u transportDataArray addObject:transportData]; 返回transportDataArray; } @结束 **运输细胞** #进口 @接口TransportCell:UITableViewCell @属性(非原子,弱)IBUILabel*nameLabel; @属性(非原子,弱)IBUIImageView*transportImageView; @属性(非原子,弱)IBUIImageView*grayedImageView; @结束 **MAINTABLEVIEWCONTROLLER.h** #进口 #输入“Transport.h” #导入“TransportDataController.h” #导入“DetailTableViewController.h” @接口MainTableViewController:UITableViewController @属性(非原子,强)TransportDataController*transportController; @属性(非原子,强)NSMutableArray*数据源; @结束 **MAINTABLEVIEWCONTROLLER.m** #导入“MainTableViewController.h” #导入“TransportCell.h” @接口MainTableViewController() @结束 @实现MainTableViewController -(无效)viewDidLoad { [超级视图下载]; _transportController=[[TransportDataController alloc]init]; self.dataSource=\u transportController.populateDataSource; self.title=@“运输类型”; } -(NSInteger)表格视图中的节数:(UITableView*)表格视图 { 返回1; } -(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节 { 返回_dataSource.count; } -(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { 静态NSString*CellIdentifier=@“mainCell”; TransportCell*cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 如果(单元格==nil) { cell=[[TransportCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } Transport*transportData=[self.dataSource objectAtIndex:indexath.row]; cell.namelab.text=transportData.name; cell.transportImageView.image=transportData.transportImage; cell.grayedImageView.image=transportData.usedTransportImage; UITapGestureRecognizer*grayedImageTouched=[[UITapGestureRecognizer alloc]initWithTarget:自我操作:@selector(transportImageTapped:)]; grayedImageTouched.numberOfTapsRequired=1; [cell.grayedImageView addgestureRecognitor:grayedImageTouched]; cell.grayedImageView.userInteractionEnabled=是; 返回单元; } -(无效)transportImageTapped:(UIgestureRecognitor*)手势 { UIImageView*选择图像视图=(UIImageView*)[手势视图]; UIImage*grayedImage=[UIImage ImageName:@“stamp grayed”]; UIImage*darkImage=[UIImage ImageName:@“邮票颜色”]; UIAlertController*transportAlert=[UIAlertController alertControllerWithTitle:@“是的,这是真的…”消息:@“我以前使用过这种类型的传输。”首选样式:UIAlertControllerStyleAlert]; [transportAlert addAction:[UIAlertAction actionWithTitle:@“取消”样式:UIAlertActionStyleCancel处理程序:^(UIAlertAction*操作){ NSLog(@“取消”); }]]; [transportAlert addAction:[UIAlertAction actionWithTitle:@“是”样式:UIAlertActionStyleDefault处理程序:^(UIAlertAction*action){ if(selectedImageView.image==灰度图像) { 选择edimageview.image=grayedImage; [选择图像视图设置图像:灰度图像]; } 其他的 { 选择edimageview.image=darkImage; [选择图像视图设置图像:暗图像]; } 如果(选择edimageview.image==darkImage) { 选择edimageview.image=darkImage; [选择图像视图设置图像:暗图像]; } 其他的 { 选择edimageview.image=grayedImage; [选择图像视图设置图像:灰度图像]; } NSLog(@“以前使用过此传输”); }]]; [transportAlert addAction:[UIAlertAction actionWithTitle:@“否”样式:UIAlertActionStyleDefault处理程序:^(UIAlertAction*操作){ 如果(选择edimageview.image==darkImage) { 选择edimageview.image=grayedImage; [选择图像视图设置图像:灰度图像]; } 其他的 { 选择edimageview.image=grayedImage; [选择图像视图设置图像:灰度图像]; } if(selectedImageView.image==灰度图像) { 选择edimageview.image=grayedImage; [选择图像视图设置图像:灰度图像]; } NSLog(@“以前从未进行过此传输”); }]]; [自我呈现视图控制器:transportAlert动画:是完成:无]; } -(void)prepareForSegue:(UIStoryboardSegue*)segue发送方:(id)发送方 { if([[segue identifier]IsequalString:@“showDetail”]) { DetailTableViewController*detailController=[segue destinationViewController]; detailController.transport=[self.dataSource objectAtIndex:[self.tableView indexPathForSelectedRow].row]; } } @结束_Ios_Objective C_Uitableview_Uiimageview - Fatal编程技术网

Ios 赞成“]; [\u transportDataArray addObject:transportData]; transportData=[[TransportAlloc]init]; transportData.name=@“商队”; transportData.transportImage=[UIImage ImageName:@“Caravan”]; transportData.usedTransportImage=[UIImage imageNamed:@“stamp grayed”]; [\u transportDataArray addObject:transportData]; 返回transportDataArray; } @结束 **运输细胞** #进口 @接口TransportCell:UITableViewCell @属性(非原子,弱)IBUILabel*nameLabel; @属性(非原子,弱)IBUIImageView*transportImageView; @属性(非原子,弱)IBUIImageView*grayedImageView; @结束 **MAINTABLEVIEWCONTROLLER.h** #进口 #输入“Transport.h” #导入“TransportDataController.h” #导入“DetailTableViewController.h” @接口MainTableViewController:UITableViewController @属性(非原子,强)TransportDataController*transportController; @属性(非原子,强)NSMutableArray*数据源; @结束 **MAINTABLEVIEWCONTROLLER.m** #导入“MainTableViewController.h” #导入“TransportCell.h” @接口MainTableViewController() @结束 @实现MainTableViewController -(无效)viewDidLoad { [超级视图下载]; _transportController=[[TransportDataController alloc]init]; self.dataSource=\u transportController.populateDataSource; self.title=@“运输类型”; } -(NSInteger)表格视图中的节数:(UITableView*)表格视图 { 返回1; } -(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节 { 返回_dataSource.count; } -(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { 静态NSString*CellIdentifier=@“mainCell”; TransportCell*cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 如果(单元格==nil) { cell=[[TransportCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } Transport*transportData=[self.dataSource objectAtIndex:indexath.row]; cell.namelab.text=transportData.name; cell.transportImageView.image=transportData.transportImage; cell.grayedImageView.image=transportData.usedTransportImage; UITapGestureRecognizer*grayedImageTouched=[[UITapGestureRecognizer alloc]initWithTarget:自我操作:@selector(transportImageTapped:)]; grayedImageTouched.numberOfTapsRequired=1; [cell.grayedImageView addgestureRecognitor:grayedImageTouched]; cell.grayedImageView.userInteractionEnabled=是; 返回单元; } -(无效)transportImageTapped:(UIgestureRecognitor*)手势 { UIImageView*选择图像视图=(UIImageView*)[手势视图]; UIImage*grayedImage=[UIImage ImageName:@“stamp grayed”]; UIImage*darkImage=[UIImage ImageName:@“邮票颜色”]; UIAlertController*transportAlert=[UIAlertController alertControllerWithTitle:@“是的,这是真的…”消息:@“我以前使用过这种类型的传输。”首选样式:UIAlertControllerStyleAlert]; [transportAlert addAction:[UIAlertAction actionWithTitle:@“取消”样式:UIAlertActionStyleCancel处理程序:^(UIAlertAction*操作){ NSLog(@“取消”); }]]; [transportAlert addAction:[UIAlertAction actionWithTitle:@“是”样式:UIAlertActionStyleDefault处理程序:^(UIAlertAction*action){ if(selectedImageView.image==灰度图像) { 选择edimageview.image=grayedImage; [选择图像视图设置图像:灰度图像]; } 其他的 { 选择edimageview.image=darkImage; [选择图像视图设置图像:暗图像]; } 如果(选择edimageview.image==darkImage) { 选择edimageview.image=darkImage; [选择图像视图设置图像:暗图像]; } 其他的 { 选择edimageview.image=grayedImage; [选择图像视图设置图像:灰度图像]; } NSLog(@“以前使用过此传输”); }]]; [transportAlert addAction:[UIAlertAction actionWithTitle:@“否”样式:UIAlertActionStyleDefault处理程序:^(UIAlertAction*操作){ 如果(选择edimageview.image==darkImage) { 选择edimageview.image=grayedImage; [选择图像视图设置图像:灰度图像]; } 其他的 { 选择edimageview.image=grayedImage; [选择图像视图设置图像:灰度图像]; } if(selectedImageView.image==灰度图像) { 选择edimageview.image=grayedImage; [选择图像视图设置图像:灰度图像]; } NSLog(@“以前从未进行过此传输”); }]]; [自我呈现视图控制器:transportAlert动画:是完成:无]; } -(void)prepareForSegue:(UIStoryboardSegue*)segue发送方:(id)发送方 { if([[segue identifier]IsequalString:@“showDetail”]) { DetailTableViewController*detailController=[segue destinationViewController]; detailController.transport=[self.dataSource objectAtIndex:[self.tableView indexPathForSelectedRow].row]; } } @结束

Ios 赞成“]; [\u transportDataArray addObject:transportData]; transportData=[[TransportAlloc]init]; transportData.name=@“商队”; transportData.transportImage=[UIImage ImageName:@“Caravan”]; transportData.usedTransportImage=[UIImage imageNamed:@“stamp grayed”]; [\u transportDataArray addObject:transportData]; 返回transportDataArray; } @结束 **运输细胞** #进口 @接口TransportCell:UITableViewCell @属性(非原子,弱)IBUILabel*nameLabel; @属性(非原子,弱)IBUIImageView*transportImageView; @属性(非原子,弱)IBUIImageView*grayedImageView; @结束 **MAINTABLEVIEWCONTROLLER.h** #进口 #输入“Transport.h” #导入“TransportDataController.h” #导入“DetailTableViewController.h” @接口MainTableViewController:UITableViewController @属性(非原子,强)TransportDataController*transportController; @属性(非原子,强)NSMutableArray*数据源; @结束 **MAINTABLEVIEWCONTROLLER.m** #导入“MainTableViewController.h” #导入“TransportCell.h” @接口MainTableViewController() @结束 @实现MainTableViewController -(无效)viewDidLoad { [超级视图下载]; _transportController=[[TransportDataController alloc]init]; self.dataSource=\u transportController.populateDataSource; self.title=@“运输类型”; } -(NSInteger)表格视图中的节数:(UITableView*)表格视图 { 返回1; } -(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节 { 返回_dataSource.count; } -(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { 静态NSString*CellIdentifier=@“mainCell”; TransportCell*cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 如果(单元格==nil) { cell=[[TransportCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } Transport*transportData=[self.dataSource objectAtIndex:indexath.row]; cell.namelab.text=transportData.name; cell.transportImageView.image=transportData.transportImage; cell.grayedImageView.image=transportData.usedTransportImage; UITapGestureRecognizer*grayedImageTouched=[[UITapGestureRecognizer alloc]initWithTarget:自我操作:@selector(transportImageTapped:)]; grayedImageTouched.numberOfTapsRequired=1; [cell.grayedImageView addgestureRecognitor:grayedImageTouched]; cell.grayedImageView.userInteractionEnabled=是; 返回单元; } -(无效)transportImageTapped:(UIgestureRecognitor*)手势 { UIImageView*选择图像视图=(UIImageView*)[手势视图]; UIImage*grayedImage=[UIImage ImageName:@“stamp grayed”]; UIImage*darkImage=[UIImage ImageName:@“邮票颜色”]; UIAlertController*transportAlert=[UIAlertController alertControllerWithTitle:@“是的,这是真的…”消息:@“我以前使用过这种类型的传输。”首选样式:UIAlertControllerStyleAlert]; [transportAlert addAction:[UIAlertAction actionWithTitle:@“取消”样式:UIAlertActionStyleCancel处理程序:^(UIAlertAction*操作){ NSLog(@“取消”); }]]; [transportAlert addAction:[UIAlertAction actionWithTitle:@“是”样式:UIAlertActionStyleDefault处理程序:^(UIAlertAction*action){ if(selectedImageView.image==灰度图像) { 选择edimageview.image=grayedImage; [选择图像视图设置图像:灰度图像]; } 其他的 { 选择edimageview.image=darkImage; [选择图像视图设置图像:暗图像]; } 如果(选择edimageview.image==darkImage) { 选择edimageview.image=darkImage; [选择图像视图设置图像:暗图像]; } 其他的 { 选择edimageview.image=grayedImage; [选择图像视图设置图像:灰度图像]; } NSLog(@“以前使用过此传输”); }]]; [transportAlert addAction:[UIAlertAction actionWithTitle:@“否”样式:UIAlertActionStyleDefault处理程序:^(UIAlertAction*操作){ 如果(选择edimageview.image==darkImage) { 选择edimageview.image=grayedImage; [选择图像视图设置图像:灰度图像]; } 其他的 { 选择edimageview.image=grayedImage; [选择图像视图设置图像:灰度图像]; } if(selectedImageView.image==灰度图像) { 选择edimageview.image=grayedImage; [选择图像视图设置图像:灰度图像]; } NSLog(@“以前从未进行过此传输”); }]]; [自我呈现视图控制器:transportAlert动画:是完成:无]; } -(void)prepareForSegue:(UIStoryboardSegue*)segue发送方:(id)发送方 { if([[segue identifier]IsequalString:@“showDetail”]) { DetailTableViewController*detailController=[segue destinationViewController]; detailController.transport=[self.dataSource objectAtIndex:[self.tableView indexPathForSelectedRow].row]; } } @结束,ios,objective-c,uitableview,uiimageview,Ios,Objective C,Uitableview,Uiimageview,远离细节,想想你在做什么 表视图显示有关有序事物集合的信息 在MVC设计模式中,表视图是视图对象,视图控制器是控制器对象 当用户以需要进行持久更改的方式与视图交互时,控制器应记录模型中的更改,并告诉视图更新其外观 然后,如果一个单元格在屏幕外滚动,然后又回到屏幕上,那么数据源应该使用数据模型中该条目的新状态设置回收的单元格 对于非分区表视图,将数据模型存储为某种数据对象的NSArray是很常见的。您可以创建自定义数据容器对象或仅使用字典 让我们 **TRANSPORT.h** #import

远离细节,想想你在做什么

表视图显示有关有序事物集合的信息

在MVC设计模式中,表视图是视图对象,视图控制器是控制器对象

当用户以需要进行持久更改的方式与视图交互时,控制器应记录模型中的更改,并告诉视图更新其外观

然后,如果一个单元格在屏幕外滚动,然后又回到屏幕上,那么数据源应该使用数据模型中该条目的新状态设置回收的单元格

对于非分区表视图,将数据模型存储为某种数据对象的NSArray是很常见的。您可以创建自定义数据容器对象或仅使用字典

让我们
**TRANSPORT.h**

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface Transport : NSObject

@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) UIImage *transportImage;
@property (nonatomic, strong) UIImage *usedTransportImage;

@end


**TRANSPORTDATACONTROLLER.h**

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "Transport.h"

@interface TransportDataController : NSObject

@property (nonatomic, strong) NSMutableArray *transportDataArray;
-(NSMutableArray *)populateDataSource;

@end


**TRANSPORTDATACONTROLLER.m**

#import "TransportDataController.h"

@implementation TransportDataController

-(NSMutableArray *)populateDataSource
{
    _transportDataArray = [[NSMutableArray alloc] init];
    Transport *transportData = [[Transport alloc] init];

    transportData.name = @"Bus";
    transportData.transportImage = [UIImage imageNamed:@"Bus"];
    transportData.usedTransportImage = [UIImage imageNamed:@"stamp-grayed"];
    [_transportDataArray addObject:transportData];

    transportData = [[Transport alloc] init];
    transportData.name = @"Helicopter";
    transportData.transportImage = [UIImage imageNamed:@"Helicopter"];
    transportData.usedTransportImage = [UIImage imageNamed:@"stamp-grayed"];
    [_transportDataArray addObject:transportData];

    transportData = [[Transport alloc] init];
    transportData.name = @"Truck";
    transportData.transportImage = [UIImage imageNamed:@"Truck"];
    transportData.usedTransportImage = [UIImage imageNamed:@"stamp-grayed"];
    [_transportDataArray addObject:transportData];

    transportData = [[Transport alloc] init];
    transportData.name = @"Boat";
    transportData.transportImage = [UIImage imageNamed:@"Boat"];
    transportData.usedTransportImage = [UIImage imageNamed:@"stamp-grayed"];
    [_transportDataArray addObject:transportData];

    transportData = [[Transport alloc] init];
    transportData.name = @"Bicycle";
    transportData.transportImage = [UIImage imageNamed:@"Bicycle"];
    transportData.usedTransportImage = [UIImage imageNamed:@"stamp-grayed"];
    [_transportDataArray addObject:transportData];

    transportData = [[Transport alloc] init];
    transportData.name = @"Motorcycle";
    transportData.transportImage = [UIImage imageNamed:@"Motorcycle"];
    transportData.usedTransportImage = [UIImage imageNamed:@"stamp-grayed"];
    [_transportDataArray addObject:transportData];

    transportData = [[Transport alloc] init];
    transportData.name = @"Plane";
    transportData.transportImage = [UIImage imageNamed:@"Plane"];
    transportData.usedTransportImage = [UIImage imageNamed:@"stamp-grayed"];
    [_transportDataArray addObject:transportData];

    transportData = [[Transport alloc] init];
    transportData.name = @"Train";
    transportData.transportImage = [UIImage imageNamed:@"Train"];
    transportData.usedTransportImage = [UIImage imageNamed:@"stamp-grayed"];
    [_transportDataArray addObject:transportData];

    transportData = [[Transport alloc] init];
    transportData.name = @"Car";
    transportData.transportImage = [UIImage imageNamed:@"Car"];
    transportData.usedTransportImage = [UIImage imageNamed:@"stamp-grayed"];
    [_transportDataArray addObject:transportData];

    transportData = [[Transport alloc] init];
    transportData.name = @"Scooter";
    transportData.transportImage = [UIImage imageNamed:@"Scooter"];
    transportData.usedTransportImage = [UIImage imageNamed:@"stamp-grayed"];
    [_transportDataArray addObject:transportData];

    transportData = [[Transport alloc] init];
    transportData.name = @"Caravan";
    transportData.transportImage = [UIImage imageNamed:@"Caravan"];
    transportData.usedTransportImage = [UIImage imageNamed:@"stamp-grayed"];
    [_transportDataArray addObject:transportData];

    return _transportDataArray; 
}

@end


**TRANSPORTCELL.h**

#import <UIKit/UIKit.h>

@interface TransportCell : UITableViewCell

@property (nonatomic, weak) IBOutlet UILabel *nameLabel;
@property (nonatomic, weak) IBOutlet UIImageView *transportImageView;
@property (nonatomic, weak) IBOutlet UIImageView *grayedImageView;

@end


**MAINTABLEVIEWCONTROLLER.h**

#import <UIKit/UIKit.h>
#import "Transport.h"
#import "TransportDataController.h"
#import "DetailTableViewController.h"

@interface MainTableViewController : UITableViewController

@property (nonatomic, strong) TransportDataController *transportController;
@property (nonatomic, strong) NSMutableArray *dataSource;

@end


**MAINTABLEVIEWCONTROLLER.m**

#import "MainTableViewController.h"
#import "TransportCell.h"

@interface MainTableViewController ()

@end

@implementation MainTableViewController

-(void)viewDidLoad
{
    [super viewDidLoad];

    _transportController = [[TransportDataController alloc] init];
    self.dataSource = _transportController.populateDataSource;
    self.title = @"Transportation Types";

}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dataSource.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"mainCell";
    TransportCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil)
    {
        cell = [[TransportCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    Transport *transportData = [self.dataSource objectAtIndex:indexPath.row];
    cell.nameLabel.text = transportData.name;
    cell.transportImageView.image = transportData.transportImage;
    cell.grayedImageView.image = transportData.usedTransportImage;

    UITapGestureRecognizer *grayedImageTouched = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(transportImageTapped:)];
    grayedImageTouched.numberOfTapsRequired = 1;
    [cell.grayedImageView addGestureRecognizer:grayedImageTouched];
    cell.grayedImageView.userInteractionEnabled = YES;


    return cell;
}


-(void)transportImageTapped:(UIGestureRecognizer *)gesture
{
    UIImageView *selectedImageView = (UIImageView *)[gesture view];
    UIImage *grayedImage = [UIImage imageNamed:@"stamp-grayed"];
    UIImage *darkImage = [UIImage imageNamed:@"stamp-color"];

    UIAlertController *transportAlert = [UIAlertController alertControllerWithTitle:@"Yes, it's true..." message:@"I have used this type of transport before." preferredStyle:UIAlertControllerStyleAlert];

    [transportAlert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action){

        NSLog(@"cancel");

    }]];

    [transportAlert addAction:[UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){

        if (selectedImageView.image == grayedImage)
        {
            selectedImageView.image = grayedImage;
            [selectedImageView setImage:grayedImage];

        }
        else
        {
            selectedImageView.image = darkImage;
            [selectedImageView setImage:darkImage];

        }

        if (selectedImageView.image == darkImage)
        {
            selectedImageView.image = darkImage;
            [selectedImageView setImage:darkImage];

        }
        else
        {
            selectedImageView.image = grayedImage;
            [selectedImageView setImage:grayedImage];

        }

        NSLog(@"has taken this transport before");


    }]];

    [transportAlert addAction:[UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){

        if (selectedImageView.image == darkImage)
        {
            selectedImageView.image = grayedImage;
            [selectedImageView setImage:grayedImage];

        }
        else
        {
            selectedImageView.image = grayedImage;
            [selectedImageView setImage:grayedImage];
        }

        if (selectedImageView.image == grayedImage)
        {
            selectedImageView.image = grayedImage;
            [selectedImageView setImage:grayedImage];
        }

        NSLog(@"has not taken this transport before");
    }]];

    [self presentViewController:transportAlert animated:YES completion:nil];

}


-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"showDetail"])
    {
        DetailTableViewController *detailController = [segue destinationViewController];
        detailController.transport = [self.dataSource objectAtIndex:[self.tableView indexPathForSelectedRow] .row];
    }
}

@end
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    ...

    // Set the UITapGestureRecognizer's image view's tag to
    // indexPath.row
    cell.grayedImageView.tag = indexPath.row;

    ...


    return cell;
}

- (void)transportImageTapped:(UIGestureRecognizer *)gesture
{
    // Fetch the datasource object associated with the current row
    Transport *transportData = [self.dataSource objectAtIndex:gesture.view.tag];

    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:gesture.view.tag inSection:0];

    UIAlertController *transportAlert = [UIAlertController alertControllerWithTitle:@"Yes, it's true..." message:@"I have used this type of transport before." preferredStyle:UIAlertControllerStyleAlert];

    [transportAlert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action){

        NSLog(@"cancel");

    }]];

    [transportAlert addAction:[UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){

        NSLog(@"has taken this transport before");

        // Create the image within the block so it's only
        // created if needed
        UIImage *darkImage = [UIImage imageNamed:@"stamp-color"];

        // Set the Transport object's "used" image to the
        // darkened image
        transportData.usedTransportImage = darkImage;

        // Replace the old Transport object associated with the
        // current row with the updated Transport object
        [self.dataSource replaceObjectAtIndex:gesture.view.tag withObject:transportData];

        // Reload the table data at that row so it reflects those changes
        [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation: UITableViewRowAnimationNone];

    }]];

    [transportAlert addAction:[UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){

        NSLog(@"has not taken this transport before");

        // Create the image within the block so it's only
        // created if needed
        UIImage *grayedImage = [UIImage imageNamed:@"stamp-grayed"];

        // Set the Transport object's "used" image to the
        // grayed image
        transportData.usedTransportImage = grayedImage;

        // Replace the old Transport object associated with the
        // current row with the updated Transport object
        [self.dataSource replaceObjectAtIndex:gesture.view.tag withObject:transportData];

        // Reload the table data at that row so it reflects those changes
        [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation: UITableViewRowAnimationNone];

    }]];

    [self presentViewController:transportAlert animated:YES completion:nil];

}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"mainCell";
TransportCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil)
{
    cell = [[TransportCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

Transport *transportData = [self.dataSource objectAtIndex:indexPath.row];
cell.nameLabel.text = transportData.name;
cell.transportImageView.image = transportData.transportImage;
if([selected containsObject:indexPath]) {
    cell.grayedImageView.image = transportData.usedTransportImage;
} else {
    cell.grayedImageView.image = transportData.deSelectedTransportImage;
}

UITapGestureRecognizer *grayedImageTouched = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(transportImageTapped:)];
grayedImageTouched.numberOfTapsRequired = 1;
[cell.grayedImageView addGestureRecognizer:grayedImageTouched];
cell.grayedImageView.userInteractionEnabled = YES;


return cell;
}

-(void)transportImageTapped:(UIGestureRecognizer *)gesture
{
CGPoint point= [gesture locationInView:self.tableView];
NSIndexPath *theIndexPath = [theTableView indexPathForRowAtPoint:point];

UIAlertController *transportAlert = [UIAlertController alertControllerWithTitle:@"Yes, it's true..." message:@"I have used this type of transport before." preferredStyle:UIAlertControllerStyleAlert];

[transportAlert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action){

    NSLog(@"cancel");

}]];

[transportAlert addAction:[UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){

    if(selected containsObject:theIndexPath ) {
        //Already selected - Remove the selection
        [selected removeObject:theIndexPath];
    } else {
        // Set the object as selected
        [selected addObjetc:theIndexPath];
    }

    NSLog(@"has taken this transport before");
    NSArray* indexArray = [NSArray arrayWithObjects:theIndexPath, nil];
    // Launch reload for the two index path
    [self.tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationFade];

}]];

[transportAlert addAction:[UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){

    if(selected containsObject:theIndexPath ) {
        //Already selected - Remove the selection
        [selected removeObject:theIndexPath];
    } else {
        // Set the object as selected
        [selected addObjetc:theIndexPath];
    }

    NSLog(@"has not taken this transport before");
    NSArray* indexArray = [NSArray arrayWithObjects:theIndexPath, nil];
    // Launch reload for the two index path
    [self.tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationFade];

}]];

[self presentViewController:transportAlert animated:YES completion:nil];