以前,我试图使用以下代码转到另一个控制器但失败了
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
RowDetail *rd = [[RowDetail alloc]initWithNibName:@"RowDetail" bundle:nil];
if ([[allRow objectAtIndex:indexPath.row] is Equal:@"One"])
{
[rd setTitle:[allRow objectAtIndex:indexPath.row]];
}
[self.navigationalController pushViewController:rd animated:NO];
}
我正在使用情节提要,所以我发现其他代码对我有用,但我无法为我正在推送的控制器设置标题。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryBoard" bundle:nil];
RowDetail *rd = [sb instantiateViewControllerWithIdentifier:@"RowDetail"];
if ([[allRow objectAtIndex:indexPath.row] is Equal:@"One"])
{
[rd setTitle:[allRow objectAtIndex:indexPath.row]];
}
[self.navigationalController pushViewController:rd animated:NO];
}
它工作并显示了 RowDetail 控制器,但我无法编辑标题。知道怎么做吗?
编辑:RowDetail.h
#import <UIKit/UIKit.h>
@interface LecturerDetail : UIViewController
@property (weak, nonatomic) IBOutlet UINavigationBar *rowNavBar;
@property (nonatomic, strong) NSString *lecDetailTitle;
@end
对于 RowDetail,我尝试使用 IBOutlet 作为导航栏,但失败了。我仍在尝试让标题显示的方法。