2012-01-31 5 views
0

Xcode 4.2를 Storyboards로 배우고 있으며 범용 앱을 만들려고합니다.Xcode 4.2 with Storyboard - 텍스트 필드가 할당되지 않았습니다.

모두 iPhone에서 잘 작동하지만 iPad 측에서는 분할보기 컨트롤러의 상세보기에 3 개의 텍스트 필드 (1 TextField, 2 TextViews)를 할당하는 데 문제가 있습니다.

스토리 보드에서 새로운 기능을 사용하여 세부 정보 헤더 파일에 대한 세부 정보 필드의 새 필드를 연결하고 자동으로 속성 및 합성 문을 작성합니다 (매우 멋진 기능).

그러나 세부 필드 (값을 메서드 drinkChanged)에 할당하고자하는 지점에 도달하면 DetailViewController보기에 아무 것도 표시되지 않습니다. 나는 사전 값이 할당 시간에 존재 함을 확인했다.

흥미로운 점은 viewWillAppear가 호출 될 때 refreshView 메소드가 호출되면 작동한다는 것입니다. 그러나 refreshView 메소드가 drinkChanged에 의해 호출되면 (사용자가 MasterViewController 테이블에서 행을 선택했음을 의미 함) 작동하지 않습니다.

어디에서 버스를 놓칠 수 있는지 알고 있습니까?

MasterViewController.h

#import <UIKit/UIKit.h> 

@interface MasterViewController : UITableViewController { 
    NSMutableArray *drinks; 
} 

@property (nonatomic, retain) NSMutableArray *drinks; 

@end 

MasterViewController.m

#import "MasterViewController.h" 
#import "DetailViewController.h" 
#import "AddDrinkViewController.h" 
#import "DrinkConstants.h" 

@implementation MasterViewController 

@synthesize drinks; 
. 
. 
. 
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

    if (!self.editing) { 

     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 

      NSLog(@"didSelectRowAtIndexPath...iPad"); 

      // Pass the selected object to the drinkChanged method in DetailViewController.m. 
      DetailViewController *splitViewDetailView = [self.storyboard instantiateViewControllerWithIdentifier:@"Detail"]; 
      [splitViewDetailView drinkChanged:[self.drinks objectAtIndex:indexPath.row]]; 
     } 
     else { 

      NSLog(@"didSelectRowAtIndexPath...iPhone"); 

      DetailViewController *detailViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Detail"]; 

      detailViewController.drink = [self.drinks objectAtIndex:indexPath.row]; 

      // Pass the selected object to the new view controller. 
      [self.navigationController pushViewController:detailViewController animated:YES]; 
     } 
    } 
    else { 

     AddDrinkViewController *editingDrinkVC = [self.storyboard instantiateViewControllerWithIdentifier:@"AddDrink"]; 

     editingDrinkVC.drink = [self.drinks objectAtIndex:indexPath.row]; 
     editingDrinkVC.drinkArray = self.drinks; 

     [self.navigationController presentModalViewController:editingDrinkVC animated:YES]; 
    } 
} 

DetailViewController.h

#import <UIKit/UIKit.h> 

@interface DetailViewController : UIViewController { 

    NSDictionary *drink; 
} 

@property (strong, nonatomic) id detailItem; 
@property (nonatomic, retain) NSDictionary *drink; 

@property (strong, nonatomic) IBOutlet UITextField *nameTextField; 
@property (strong, nonatomic) IBOutlet UITextView *ingredientsTextView; 
@property (strong, nonatomic) IBOutlet UITextView *directionsTextView; 

- (void) refreshView; 
- (void) drinkChanged:(NSDictionary *) newDrink; 

@end 

DetailViewController :

여기 내 코드입니다. m NSLog에서

GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 8 20:32:45 UTC 2011) 
Copyright 2004 Free Software Foundation, Inc. 
GDB is free software, covered by the GNU General Public License, and you are 
welcome to change it and/or distribute copies of it under certain conditions. 
Type "show copying" to see the conditions. 
There is absolutely no warranty for GDB. Type "show warranty" for details. 
This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all 
Attaching to process 1187. 
2012-01-31 13:10:26.061 DrinkMixer[1187:f803] viewDidLoad 
2012-01-31 13:10:26.087 DrinkMixer[1187:f803] viewWillAppear 
2012-01-31 13:10:26.088 DrinkMixer[1187:f803] refreshView 
2012-01-31 13:10:26.089 DrinkMixer[1187:f803] NAME_KEY  = (null) 
2012-01-31 13:10:26.090 DrinkMixer[1187:f803] INGREDIENTS_KEY = (null) 
2012-01-31 13:10:26.090 DrinkMixer[1187:f803] DIRECTIONS_KEY = (null) 
2012-01-31 13:10:26.091 DrinkMixer[1187:f803] nameTextField  = (null) 
2012-01-31 13:10:26.091 DrinkMixer[1187:f803] ingredientsTextView = 
2012-01-31 13:10:26.092 DrinkMixer[1187:f803] directionsTextView = 
2012-01-31 13:10:32.878 DrinkMixer[1187:f803] didSelectRowAtIndexPath...iPad 
2012-01-31 13:10:32.879 DrinkMixer[1187:f803] drinkChanged 
2012-01-31 13:10:32.879 DrinkMixer[1187:f803] refreshView 
2012-01-31 13:10:32.880 DrinkMixer[1187:f803] NAME_KEY  = Blue Dog 
2012-01-31 13:10:32.880 DrinkMixer[1187:f803] INGREDIENTS_KEY = vodka,grapefruit juice 
2012-01-31 13:10:32.881 DrinkMixer[1187:f803] DIRECTIONS_KEY = Combine both while cold. 
2012-01-31 13:10:32.881 DrinkMixer[1187:f803] nameTextField  = (null) 
2012-01-31 13:10:32.882 DrinkMixer[1187:f803] ingredientsTextView = (null) 
2012-01-31 13:10:32.882 DrinkMixer[1187:f803] directionsTextView = (null) 

마지막 3 줄 내가 사전 키의 값을 얻을 것으로 기대하고 있습니다 대신 그들이 다시 (NULL)을하는 곳입니다

NSLog 출력.

답변