我有一个使用情节提要的项目。我有一个UIView
,我在视图底部放了一些图像和按钮,我放了一个UITableView
. 我把这段代码放在UIView.h
.
interface MenuViewController : UIViewController<UITableViewDelegate, UITableViewDataSource>
{
IBOutlet UITableView *MenuTable;
NSMutableArray *TabloMenu;
id menuler;
}
@property (nonatomic, retain) IBOutlet UITableView *MenuTable;
@property (nonatomic, retain) NSMutableArray *TabloMenu;
并在iuview.m
:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)table {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [TabloMenu count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"CellFirmalar";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
menuler = [TabloMenu objectAtIndex:[indexPath row]];
cell.textLabel.text = [menuler objectForKey:@"Tanim"];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *alertString = [NSString stringWithFormat:@"Clicked on row #%d", [indexPath row]];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:alertString message:@"" delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil];
[alert show];
}
直到这里一切都运行良好。当我单击显示单元格行号时,数据即将到来。我UITableViewController
在情节提要上添加了新内容并将 tableview 链接到UITableViewController
segue
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([[segue identifier] isEqualToString:@"Records"]){
ResultTableViewController *cvc = (ResultTableViewController *)[segue destinationViewController];
}
}
但它并没有改变这一点。我该如何切换这个UITableViewController
?感谢所有帮助。