Я пытался следовать этому уроку: http://www.youtube.com/watch?v=L-FK1TrpUng&feature=related около 00: 39: 00.
Здесь есть счетчик, который распознает каждое переключение на второй контроллер вида и считает его.Количество переключателей вида должно отображаться на втором контроллере вида.Но это не работает, вот код: Test2ViewController.h
@interface Test2ViewController : UIViewController <UITextFieldDelegate> {
UINavigationController *navController;
Test21ViewController *test21View;
NSString *text;
IBOutlet UITextField *textField1;
}
@property(nonatomic, retain) UITextField *textField1;
@property (nonatomic, retain) UINavigationController *navController;
@property (copy) NSString *text;
-(IBAction)pushViewController:(id)sender;
@end
Test2ViewController.m:
# import "Test2ViewController.h" #import "Test21ViewController.h"
@implementation Test2ViewController
@synthesize textField1, navController, text;
-(IBAction)pushViewController:(id)sender {
static int count = 1;
Test21ViewController *test21ViewController = [[Test21ViewController alloc] init];
[self.navigationController pushViewController:test21ViewController animated:YES];
test21ViewController.label = [NSString stringWithFormat:@"Pushed %d", count];
count++;
}
Test21ViewController.h:
@interface Test21ViewController : UIViewController {
UINavigationController *navController;
NSString *label;
IBOutlet UILabel *textLabel;
UITextField *tF1;
}
@property (copy) NSString *label;
@property (nonatomic, retain) UINavigationController *navController;
@property(nonatomic,retain)UITextField *tF1;
-(IBAction)feldeingabe:(id)Sender;
@end
Test21ViewController.m:
@implementation Test21ViewController
@synthesize label;
- (void)viewDidLoad {
textLabel.text = label;
}
Есть идеи, почему это не работает?Заранее спасибо
Код для второго вопроса:
static int count = 1;
Test2ViewController *test2ViewController;
test2ViewController.label = [NSString stringWithFormat:@"Pushed %d !!!!!", count];
[[self navigationController] popViewControllerAnimated:NO];
count++;
ТЕКУЩИЙ КОД:
#import "Test21ViewController.h"
@implementation Test21ViewController
@synthesize navController, text, parentView;
-(IBAction)pushViewController2:(id)sender {
Test2ViewController *test2ViewController;
static int count = 1;
test2ViewController.parentView = self;
test2ViewController.label = [NSString stringWithFormat:@"Pushed %d !!!!!", count];
[self.navigationController pushViewController:test2ViewController animated:YES]; count++;
}