Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.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
Iphone 在类似TableCell的实用程序中翻转_Iphone_Xcode_Uitableview_Uiviewcontroller_Uinavigationcontroller - Fatal编程技术网

Iphone 在类似TableCell的实用程序中翻转

Iphone 在类似TableCell的实用程序中翻转,iphone,xcode,uitableview,uiviewcontroller,uinavigationcontroller,Iphone,Xcode,Uitableview,Uiviewcontroller,Uinavigationcontroller,我对tableViewCell有一些疑问 表单元格/行的数组中添加了许多值。现在,每个单元格的信息按钮都是静态的。数组的每个元素都有字典,它有两个值,cellvalue和detail值 现在,当用户单击“信息”按钮时,单元格本身会翻转并显示其详细信息 请看,我们有实用程序应用程序作为翻转的示例,但在实用程序应用程序中,整个视图控制器被翻转 我尝试了以下代码 作为此翻转动画的示例: 开放式仪表板 在屏幕上拖动时钟 现在看时钟,它的底部有信息按钮 点击那个按钮 时钟将被翻转 现在点击done。它将

我对
tableViewCell
有一些疑问

表单元格/行的数组中添加了许多值。现在,每个单元格的信息按钮都是静态的。数组的每个元素都有字典,它有两个值,
cellvalue
detail

现在,当用户单击“信息”按钮时,单元格本身会翻转并显示其详细信息

请看,我们有实用程序应用程序作为翻转的示例,但在实用程序应用程序中,整个视图控制器被翻转

我尝试了以下代码

作为此翻转动画的示例:

  • 开放式仪表板
  • 在屏幕上拖动时钟
  • 现在看时钟,它的底部有信息按钮
  • 点击那个按钮
  • 时钟将被翻转
  • 现在点击done。它将再次翻转到原始状态
我想实现同样的功能,我有两个值

-(void)btnInfoTapped:(NSDictionary*)sender cellID:(NSString*)cellID{
    if(tmpVCtr!=nil && [tmpVCtr retainCount]>0){ [tmpVCtr release]; tmpVCtr=nil; }
    tmpVCtr=[[UIViewController alloc] init]; // temp view controller
    if(nxtEventInfoVCtr!=nil && [nxtEventInfoVCtr retainCount]>0){ [nxtEventInfoVCtr release]; nxtEventInfoVCtr=nil; }  // a view controller which is going to be flipped.
    nxtEventInfoVCtr=[[EventInfoVCtr alloc] initWithNibName:@"EventInfoVCtr" bundle:nil];
    nxtEventInfoVCtr.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
    NSLog(@"%@",[sender description]);
    // here i am settings values for flipped view controller
if([sender valueForKey:@"pendingextratext"]){
    nxtEventInfoVCtr.strText=[sender valueForKey:@"pendingextratext"];
    nxtEventInfoVCtr.strTitle=[sender valueForKey:@"pendingdescription"];
    CustomCellPending *tmp=(CustomCellPending *)[tblMain dequeueReusableCellWithIdentifier:cellID];
    [tmpVCtr setView:[tmp backgroundView]];
    [tmpVCtr presentModalViewController:nxtEventInfoVCtr animated:YES];
} else {
    nxtEventInfoVCtr.strText=[sender valueForKey:@"payextratext"];
    nxtEventInfoVCtr.strTitle=[sender valueForKey:@"paydescription"];
    CustomCellPay *tmp=(CustomCellPay *)[tblMain dequeueReusableCellWithIdentifier:cellID];
    [tmpVCtr setView:[tmp backgroundView]];
    [tmpVCtr presentModalViewController:nxtEventInfoVCtr animated:YES];
}
     }

我想要的是翻转单元格中的视图控制器。有可能吗?

首先,这可能只是个人喜好,但您的代码有点凌乱-您知道的一些换行符没有问题;)

关于您的问题,我建议您在单元格中使用两个视图-一个是单元格的默认contentView,另一个是您自己创建的自定义视图

然后,您可以将一些代码写入表视图控制器,该控制器将响应info按钮的按下。该方法应使用indexpath确定将翻转哪个表单元格,然后使用核心动画或带有翻转转换的简单UIView动画执行标准视图翻转

重要的是要知道,默认情况下,每个
tableViewCell
都没有自己的控制器(如果需要,您可以创建一个控制器),因此在处理表视图单元格时,您感兴趣的大部分内容都将由表视图控制器处理

事情看起来:

  • UIView动画
    • +beginAnimations:forContext:
    • +setAnimationTransition:forView:cache:
  • 自定义表格单元格视图的
    • 表格单元格的绘制方式

我已将视图控制器的视图添加到单元视图中。 意味着

现在,每个视图控制器中都有两个视图。 视图控制器有按钮和打开按钮点击事件我正在翻转视图

请参阅,以下代码-是视图控制器的代码&该视图控制器的视图已添加到单元格中

-(IBAction)btnInfoTapped:(id)sender{
    CGContextRef context = UIGraphicsGetCurrentContext();
    [UIView beginAnimations:nil context:context];
    [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:viewMain cache:YES];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:1.0];
    [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(hideMainView) userInfo:nil repeats:NO];
    [UIView commitAnimations];
}
-(void)hideMainView{
    [viewMain addSubview:viewInfo];
}

-(IBAction)btnBack:(id)sender{
    CGContextRef context = UIGraphicsGetCurrentContext();
    [UIView beginAnimations:nil context:context];
    [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:viewMain cache:YES];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:1.0];
    [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(hideInfoView) userInfo:nil repeats:NO];
    [UIView commitAnimations];
}

-(void)hideInfoView {
    [viewInfo removeFromSuperview];
}

简言之,我遵循了@Jasarien所说的方式。使用UIView动画是他的想法。
-(IBAction)btnInfoTapped:(id)sender{
    CGContextRef context = UIGraphicsGetCurrentContext();
    [UIView beginAnimations:nil context:context];
    [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:viewMain cache:YES];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:1.0];
    [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(hideMainView) userInfo:nil repeats:NO];
    [UIView commitAnimations];
}
-(void)hideMainView{
    [viewMain addSubview:viewInfo];
}

-(IBAction)btnBack:(id)sender{
    CGContextRef context = UIGraphicsGetCurrentContext();
    [UIView beginAnimations:nil context:context];
    [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:viewMain cache:YES];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationDuration:1.0];
    [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(hideInfoView) userInfo:nil repeats:NO];
    [UIView commitAnimations];
}

-(void)hideInfoView {
    [viewInfo removeFromSuperview];
}