ard*_*vis 12 uitableview ios segue
我有一个自定义的UITableViewCell,叫做EventCell.
EventCell.h
#import <UIKit/UIKit.h>
@interface EventCell : UITableViewCell
@property (nonatomic, strong) IBOutlet UILabel *titleLabel;
@property (nonatomic, strong) IBOutlet UILabel *locationLabel;
@property (nonatomic, strong) IBOutlet UILabel *dateLabel;
@property (nonatomic, strong) IBOutlet UILabel *typeLabel;
@end
Run Code Online (Sandbox Code Playgroud)
EventCell.m
#import "EventCell.h"
@implementation EventCell
@synthesize titleLabel, locationLabel, dateLabel, typeLabel;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
Run Code Online (Sandbox Code Playgroud)
这是我如何设置我的单元格.
EventsMasterViewController.m
- (EventCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
Event *myEvent;
NSString *CellIdentifier = @"EventCell";
EventCell *cell = (EventCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"EventCell" owner:nil options:nil];
for (id currentObject in topLevelObjects)
{
if ([currentObject isKindOfClass:[EventCell class]])
{
cell = (EventCell *)currentObject;
break;
}
}
myEvent = [self.myEventsDataController objectInListAtIndex:indexPath.row];
cell.titleLabel.text = myEvent.name;
cell.locationLabel.text = myEvent.location;
cell.typeLabel.text = @"Social";
cell.layer.borderColor = [UIColor blackColor].CGColor;
cell.layer.borderWidth = 1.0;
return cell;
}
Run Code Online (Sandbox Code Playgroud)
该单元格格式很好,看起来完全符合我的要求.但是当我点击它时,单元格会突出显示蓝色并且不会转到下一个视图.我在prepareForSegue方法中放了一个断点,它甚至没有被调用.
有没有办法手动调用prepareForSegue?如果是这样,我应该在哪里做.
Des*_*ova 25
你需要实施
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self performSegueWithIdentifier:@"YourSegueIdentifier" sender:nil];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9349 次 |
| 最近记录: |