2012-11-30 39 views
0

我需要幫助。我有一個tableView的觀點,當我點擊一個單元格時,它向我展示了另一個視圖mapView。你如何在另一個類中使用一個類的字符串?如何在iOS上的另一個類中使用一個類的字符串?

+0

看到這一點 - [iOS版 - 傳遞變量到視圖控制器(http://stackoverflow.com/問題/ 11272864/ios-passing-variable-to-view-controller/11274661#11274661) – TheTiger

+0

看到這個問題:-http://stackoverflow.com/questions/13245100/how-to-access-first-class-method- from-second-class-in-objective-c/13245178#13245178 –

+0

我這樣做了,但它不起作用:( – sliwek

回答

0

請地圖視圖控制器寫

在地圖視圖控制器的.m文件地圖視圖控制器

@property(nonatomic,retain)NSString* strToSend; 

的.h文件中

@synthesis strToSend; 

在基礎viewCon中troller其中的TableView編程

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    MapView* mapObj = [[MapView alloc]initWithNibName:@"MapView" bundle:nil]; 
    mapObj.strToSend = @"Text To Send"; // you can send string to MapView controller via this string object 
    [self.navigationController pushViewController:mapObj animated:YES]; 
    [mapObj release]; 
} 
+0

非常感謝你 – sliwek

0

在下一個視圖中創建@Property (nonatomaic,retain) NSString *stringToshow;,並在didSelectRowAtIndexPath代表UITableView中指定其值。

相關問題