目前,当选择单元格时,标签上显示先前选择的单元格内容.这是我的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时,我的视图控制器标签就是一个动作所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)