Ios 在表格单元格上显示图像单击

Ios 在表格单元格上显示图像单击,ios,objective-c,Ios,Objective C,我正在创建一个iPhone应用程序。因为我正在表格单元格中显示一些内容。现在,我想在单击表格单元格时显示全尺寸图像。 我使用了以下代码。但是当我选择表格单元格时,我不知道如何全屏显示图像。 而且,当我在全屏画面中点击背景时,我想返回 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { CustomTableViewCell *cell = [

我正在创建一个iPhone应用程序。因为我正在表格单元格中显示一些内容。现在,我想在单击表格单元格时显示全尺寸图像。 我使用了以下代码。但是当我选择表格单元格时,我不知道如何全屏显示图像。 而且,当我在全屏画面中点击背景时,我想返回

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"CustomCell"];
const char *dbpath = [_databasePath UTF8String];
sqlite3_stmt    *statement;

if (sqlite3_open(dbpath, &_beaconDB) == SQLITE_OK)
{

    NSString *querySQL = [NSString stringWithFormat:
                          @"SELECT vendor_name, enter_message, enter_image, received_date, time_interval FROM beacons WHERE id=%@",  [unique objectAtIndex:indexPath.row]];
    const char *query_stmt = [querySQL UTF8String];
    if (sqlite3_prepare_v2(_beaconDB,
                       query_stmt, -1, &statement, NULL) == SQLITE_OK)
    {
        if (sqlite3_step(statement) == SQLITE_ROW)
        {
            title = [[NSString alloc]
                              initWithUTF8String:
                              (const char *) sqlite3_column_text(
                                                                 statement, 0)];
            description = [[NSString alloc]
                            initWithUTF8String:(const char *)
                            sqlite3_column_text(statement, 1)];

            fullImg = [[NSString alloc]
                           initWithUTF8String:(const char *)
                           sqlite3_column_text(statement, 2)];

            NSString *receivedDate = [[NSString alloc]
                                     initWithUTF8String:(const char *)
                                     sqlite3_column_text(statement, 3)];

            NSString *timeInterval = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 4)];

            BeaconAdTime *beaconAdTime = [[BeaconAdTime alloc] init];
            NSDate *updatedTime = [beaconAdTime updatedDateTime:receivedDate andInterval:[timeInterval intValue]];

            while (updatedTime!=nil)
            {
                NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
                [dateFormatter setDateFormat: @"MMM-dd hh:mm a"];
                BeaconAdTime *beaconAdTime = [[BeaconAdTime alloc] init];
                NSString *presentDateTime = [beaconAdTime presentDateTime];
                NSDate *presentDateConvert = [dateFormatter dateFromString:presentDateTime];

                if(updatedTime <= presentDateConvert)
                {
//                        [message insertObject:description atIndex:indexPath.row];
//                        [vendor insertObject:title atIndex:indexPath.row];
                    cell.title.text = title;
                    cell.description.text = description;
                    cell.receivedDate.text = receivedDate;
                    break;
                }
            }
        }
    sqlite3_finalize(statement);
    }
    sqlite3_close(_beaconDB);
}
cell.title.text = vendor[indexPath.row];

cell.vendorImage.image = [UIImage imageNamed:@"gg.jpg"];

//    cell.imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:thumbnailImg]]];
return cell;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
CustomTableViewCell*单元格=[self.tableView dequeueReusableCellWithIdentifier:@“CustomCell”];
const char*dbpath=[\u databasePath UTF8String];
sqlite3_stmt*语句;
if(sqlite3_打开(dbpath和beaconDB)=SQLITE_正常)
{
NSString*querySQL=[NSString stringWithFormat:
@“选择供应商名称,输入消息,输入图像,从信标接收日期,时间间隔,其中id=%@,[unique objectAtIndex:indexath.row]];
const char*query_stmt=[querySQL UTF8String];
如果(sqlite3)准备好了v2,
查询\u stmt,-1,&语句,NULL)==SQLITE\u OK)
{
if(sqlite3_步骤(语句)==SQLITE_行)
{
title=[[NSString alloc]
initWithUTF8String:
(常量字符*)sqlite3\u列\u文本(
声明,0)];
description=[[NSString alloc]
initWithUTF8String:(常量字符*)
sqlite3_列_文本(语句,1)];
fullImg=[[NSString alloc]
initWithUTF8String:(常量字符*)
sqlite3_列_文本(语句,2)];
NSString*receivedDate=[[NSString alloc]
initWithUTF8String:(常量字符*)
sqlite3_列_文本(语句,3)];
NSString*timeInterval=[[NSString alloc]initWithUTF8String:(const char*)sqlite3_column_text(语句,4)];
BeaconAdTime*BeaconAdTime=[[BeaconAdTime alloc]init];
NSDate*updatedTime=[beaconAdTime updatedDateTime:receivedDate and Interval:[timeInterval intValue]];
while(updateTime!=nil)
{
NSDateFormatter*dateFormatter=[[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@“mm dd hh:mm a”];
BeaconAdTime*BeaconAdTime=[[BeaconAdTime alloc]init];
NSString*presentDateTime=[beaconAdTime presentDateTime];
NSDate*presentDateConvert=[dateFormatter dateFromString:presentDateTime];
如果(updatedTime类似于:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = tableView.visibleCells[indexPath.row];
    UIViewController *imageVC = [UIViewController new];
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    CGFloat screenWidth = screenRect.size.width;
    CGFloat screenHeight = screenRect.size.height;
    imageVC.view.frame = CGRectMake(0, 0, screenWidth, screenHeight);
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:imageVC.view.frame];
    imageView.image = cell.imageView.image;
    imageView.userInteractionEnabled=YES;
    UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageTouched:)];
    [imageView addGestureRecognizer:tapGR];
    [self presentViewController:imageVC animated:YES completion:nil];

}

如果您需要解释和/或进一步帮助,请告诉我

我想您需要的是一个深入的表格界面

这是Ray Wenderlich的一个例子:。另外,这是苹果公司的官方参考资料:


祝你好运!

嘿,你可以将UIImageView对象添加到同一屏幕上,使其具有设备的完整大小,并将其初始隐藏。然后添加-(void)tableView:(UITableView*)tableView DidSelectRowatineXpath:(NSIndexPath*)indexPath;委托tableview的方法,并将所选图像设置为UIImageview对象并使其隐藏为FALSE……一旦看到整个屏幕覆盖的图像,您可以通过点击手势识别器方法将其再次隐藏。添加
imageView.userInteractionEnabled=YES;
1。在UITableViewController上,您正在覆盖该对象s方法。2.您正在使用UIImageView创建视图控制器-两者都具有屏幕大小。3.您添加了点击手势。4.您展示了它。如果您希望照片仅覆盖部分照片,只需更改UIImageView的框架。在点击手势识别器的方法中-“imageTouched”您可以检查触摸是否在照片内部或背景上。target-当接收者识别手势时,作为接收者发送的动作消息的接收者的对象。nil不是有效值。action-一个选择器,用于识别目标为处理接收者识别的手势而实现的方法。action选择器st符合类概述中描述的签名。NULL不是有效值。如果将光标放在方法签名上,您可以在屏幕左侧看到变量的描述。它对您有效吗?您可以确认答案(通过检查v)?这里我使用自定义单元格查看表格。上面的代码有效吗?还是我必须更改一些内容