【发布时间】:2012-05-18 07:25:04
【问题描述】:
我有一个使用情节提要的项目。我有一个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?感谢大家的帮助。
【问题讨论】:
标签: ios uitableview uiview uistoryboard