2013-09-23 64 views
1

我已經在我的應用程序中完成了以前的以下代碼。它與iOS7以外的所有iOS一起工作良好。我改變didSelectRow方法導航標題,但它並沒有改變我的導航欄標題中的iOS 7.我在didselectrow創建運行時新的控制器,並給予它在這行nextController.title = [dataDict objectForKey: kNestedDataKey_title];導航標題在iOS 7中沒有變化

- (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath { 

    NSLogDebug(); 
    NSDictionary *dataDict = [self.data objectAtIndex: indexPath.row]; 
    NSString *classNSString = [dataDict objectForKey: kNestedDataKey_class]; 

    UIViewController *nextController = NULL; 
     nextController = [[NestedTableViewController alloc] initWithNibName: nil bundle: nil]; 
     [self.navigationController pushViewController: nextController animated: YES]; 
     ((NestedTableViewController *) nextController).data = [dataDict objectForKey: kNestedDataKey_data]; 


    nextController.title = [dataDict objectForKey: kNestedDataKey_title]; 
    [nextController release]; 
} 

註標題:它在所有iOS的比iOS的7其它

+0

我得到了同樣在這裏。我初始化一個detailViewController白色筆尖,進行推送,並從選定的項目傳遞一個字符串到detailViewController的標籤。標籤不更新..任何解決方案?? – Frade

+0

你正在改變你的init方法嗎?在init方法中傳遞它,然後將它分配給其他NSString,然後在viewDidLoad方法中設置標題。 – Mashhadi

+0

不,我在didSelectRowAtIndexPath中啓動一個新的detailViewController。這個新的detailViewController有一個IBOutlet,一個標籤。推進後,我分配標籤文本,但它不會改變(在iOS的7好好嘗試的工作,這個工作在以前所有的iOS。是模板代碼) – Frade

回答

1

我注意到的iOS 7一個奇怪的行爲,在存儲位這一觀點負載晚。所以當你設置標題時,可能標題標題還沒有創建。所以在設置瓷磚前請使用此聲明。這將確保您的視圖在內存中創建。 [nextController view]; 此集標題後 nextController.title = @「標題」; 好運

+0

你得到了根本原因[nextController視圖];不是爲我,但問題的工作是iOS7加載有點晚了,所以我剛纔添加一個NSTimer它。用1.0秒,並且它的工作 [的NSTimer scheduledTimerWithTimeInterval:1.0目標:自選擇器:@selector(變化)USERINFO:無重複:NO]; – Mashhadi

+0

這很好,祝賀。 –

1

工作正常,試試這個代碼

- (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath { 
    NSLogDebug(); 
    NSDictionary *dataDict = [self.data objectAtIndex: indexPath.row]; 
    NSString *classNSString = [dataDict objectForKey: kNestedDataKey_class]; 

    NestedTableViewController *nextController = NULL; 
    nextController = [[NestedTableViewController alloc] initWithNibName: nil bundle: nil]; 

    nextController.data = [dataDict objectForKey: kNestedDataKey_data]; 


    nextController.title = [dataDict objectForKey: kNestedDataKey_title]; 
    [self.navigationController pushViewController: nextController animated: YES]; 
    [nextController release]; 
} 
+0

仍然沒有運氣:( – Mashhadi

+0

請參閱我的更新回答 – Deepesh

+0

initWithNibName ..您傳遞的筆尖名稱.... – Deepesh