ios – 当我选择UITableViewCell时,我的视图控制器标签就是一个动作

ios – 当我选择UITableViewCell时,我的视图控制器标签就是一个动作,第1张

概述我有一个视图控制器设置与表视图.我还有一个方法,当选择一个表视图的单元格时,该方法应该推送到新的视图控制器.新的视图控制器包含一个标签,我希望标签显示所选单元格内容的全文. 目前,当选择单元格时,标签上显示先前选择的单元格内容.这是我的ViewController.m文件的当前内容(委托和数据源在头文件中声明) #import "ViewController.h" @interfac 我有一个视图控制器设置与表视图.我还有一个方法,当选择一个表视图的单元格时,该方法应该推送到新的视图控制器.新的视图控制器包含一个标签,我希望标签显示所选单元格内容的全文.

目前,当选择单元格时,标签上显示先前选择的单元格内容.这是我的VIEwController.m文件的当前内容(委托和数据源在头文件中声明)

#import "VIEwController.h"    @interface VIEwController ()@property (weak,nonatomic) IBOutlet UItableVIEw *tableVIEw;@property (strong,nonatomic) NSArray *tweetsArray;@end@implementation VIEwController- (voID)vIEwDIDLoad{    self.tableVIEw.dataSource = self;    self.tableVIEw.delegate = self;    self.tweetsArray = [[NSArray alloc] initWithObjects:                   @"Lorem ipsum dolor sit amet,consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum socIIS natoque penatibus",@"eleifend ac,enim. Aliquam lorem ante,dAPIbus in,viverra quis,feugiat a,tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdIEt. Etiam ultricIEs nisi vel augue. Cu",@" Nam quam nunc,blandit vel,luctus pulvinar,hendrerit ID,lorem. Maecenas nec odio et ante tincIDunt tempus. Donec vitae sAPIen ut libero v",@" eros faucibus tincIDunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec soDales sagittis magna. Sed consequat,leo eget bibendum soDales",nil];    [super vIEwDIDLoad];    // Do any additional setup after loading the vIEw,typically from a nib.}- (voID)dIDReceiveMemoryWarning{    [super dIDReceiveMemoryWarning];    // dispose of any resources that can be recreated.}- (NSInteger) tableVIEw:(UItableVIEw *)tableVIEw numberOfRowsInSection:(NSInteger)section{    return self.tweetsArray.count;}- (UItableVIEwCell *) tableVIEw:(UItableVIEw *)tableVIEw cellForRowAtIndexPath:(NSIndexPath *)indexPath{    static Nsstring *cellIDentifIEr = @"SettingsCell";    UItableVIEwCell *cell = [tableVIEw dequeueReusableCellWithIDentifIEr:cellIDentifIEr];    Nsstring *tweet = [self.tweetsArray objectAtIndex:indexPath.row];    [cell.textLabel setText:tweet];    [cell.detailTextLabel setText: @"Cody be Cray"];    return cell;}- (voID) tableVIEw:(UItableVIEw *)tableVIEw dIDdeselectRowAtIndexPath:(NSIndexPath *)indexPath{    DetailVIEwController *dvc = [self.storyboard instantiateVIEwControllerWithIDentifIEr: @"DetailVIEwController"];    dvc.tweet = [self.tweetsArray objectAtIndex:indexPath.row];    [self.navigationController pushVIEwController:dvc animated:YES];}@end
解决方法 你有一个“dIDdeselect”而不是“dIDSelect”tablevIEw委托方法.

- (voID) tableVIEw:(UItableVIEw *)tableVIEw dIDdeselectRowAtIndexPath:(NSIndexPath *)indexPath{    ...}

应该是这样的:

- (voID) tableVIEw:(UItableVIEw *)tableVIEw dIDSelectRowAtIndexPath:(NSIndexPath *)indexPath{    ...}
总结

以上是内存溢出为你收集整理的ios – 当我选择UITableViewCell时,我的视图控制器标签就是一个动作全部内容,希望文章能够帮你解决ios – 当我选择UITableViewCell时,我的视图控制器标签就是一个动作所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1076954.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存