2011-04-08 14 views
1

這真是令人沮喪,因爲我已經在Xcode以前的版本修修補補之前,但現在有一個新的應用程序玩弄已經做到了這一點,它不工作的某些原因。的iOS/Xcode的4:查看不會加載

我打開應用程序後,以一個UITableView,想一旦我選擇一個單元格它加載到一個細節的UIView。但是,當我在iPhone模擬器中選擇一個單元格時,它會突出顯示單元格藍色並且不加載視圖。

這裏是我使用的RootViewController的代碼:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
WorkoutViewController *workoutViewController; 
workoutViewController = [[WorkoutViewController alloc] initWithNibName:@"WorkoutViewController" bundle:nil]; 
workoutViewController.workoutName = [workouts objectAtIndex:indexPath.row]; 
[self.navigationController pushViewController:workoutViewController animated:YES]; 
[workoutViewController release]; 
workoutViewController = nil; 

我有鏈接到WorkoutViewController.xib文件中的文件所有者的視圖。當我在@implementation WorkoutViewController中放置一個斷點時,它會到達該斷點,但它會轉到@synthesize行,然後再跳回到[self.navigationController ... etc];並且永遠不會返回到WorkoutViewController.m文件。

+0

我沒有看到你在做什麼錯。也許我們需要看到更多的代碼。 didSelectRowAtIndexPath被觸發(如斷點所示),它的原因是@synthesize是我假設你有workoutName作爲workoutViewController中的一個屬性。 – Tobias 2011-04-08 21:25:22

回答

1

我猜你沒有設置視圖控制器是TableView中的代表。要檢查,打開你的ViewController的xib文件,並右鍵點擊FilesOwner。在Referencing Outlet你通常會同時擁有delegatedata源」連接到您的TableView。如果不是的話,拖New Referencing Outlet您的TableView。

如果我錯了,他們都連接,你可能想要把斷點在你didSelectRowAtIndexPath方法。一開始是否調試器停在那裏,一旦你選擇了某一行?

它也可能是值得一提的是,在@implementation斷點通常不會太大的意義,你寧願要放置它在像init這樣的方法中。另外,即使你現在使用Xcode 4,這不太可能是你的問題的原因,它看起來更像是一個實現問題即

希望這會有所幫助,如果您需要進一步的幫助,只是讓我知道!

+0

有人可以啓發我,爲什麼這被否決嗎?謝謝 – Phlibbo 2011-10-13 23:31:11

1

衛生署!問題已解決。我忘記了將RootViewController放到MainWindow.xib的導航控制器中。欣賞迴應。