我有兩個視圖控制器。在第一個視圖控制器中,我有名稱列表。當我點擊它時,我想要在第二個視圖控制器中顯示相同的名稱。的UILabel文本不改變,但是xx.title工作
我有下面的代碼。
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// PropDetailViewController is second view controller
PropDetailViewController *prop = [self.storyboard instantiateViewControllerWithIdentifier:@"prop"];
ListOfProperty *propList = [propListFinal objectAtIndex:indexPath.row];
NSString *myText = [NSString stringWithFormat:@"%@", propList.addressOfFlat];
prop.detailLabel.text = myText;
prop.title = myText;
[self.navigationController pushViewController:prop animated:YES];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
和PropDetailViewController
,我有@property (retain, nonatomic) IBOutlet UILabel *detailLabel;
。
我期待的是當我點擊說Name 1
時,我會在UILabel和UINavigationBar中看到Name 1
作爲文本。但是,我只在導航欄上看到Name 1
,而不是在UILabel上。
也有類似的問題前幾天,但我沒有找到它。但是,如果我找不到它,我會嘗試一個答案。 –
如果它不起作用,爲什麼不嘗試在PropDetailViewController中使用detailLabel.text = title! –
@Dpk:這很好,但實際上我不想顯示標題。在標題我將靜態文本爲「names」 –