HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 当我选择UITableViewCell时,我的视图控制器标签就是一个动作大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个视图控制器设置与表视图.我还有一个方法,当选择一个表视图的单元格时,该方法应该推送到新的视图控制器.新的视图控制器包含一个标签,我希望标签显示所选单元格内容的全文.

目前,当选择单元格时,标签显示先前选择的单元格内容.这是我的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 NS@R_450_10495@ng *cellIdentifier = @"SetTingsCell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    NS@R_450_10495@ng *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时,我的视图控制器标签就是一个动作所遇到的程序开发问题。

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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。