我從我的UIViewController創建一個類對象,並嘗試從它推動控制器,它不會工作。PushViewController從另一個類的當前導航控制器
我一直在做研究,但沒有發現任何想法?
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.newClass = [[MyNewClass alloc] init];
self.newClass.view = self.view;
self.newClass.navigationController = self.navigationController;
[self.newClass connect];
}
...
@end
MyNewClass.h
@interface MyNewClass : NSObject<UINavigationControllerDelegate>
@property(nonatomic, retain) UIView *view;
@property(nonatomic, retain) UINavigationController *navigationController;
-(void) connect;
@end
MyNewClass.m
-(void)connect
{
OtherViewController * otherVC =
[[OtherViewController alloc] init];
self.navigationController pushViewController:otherVC animated:YES];
}
...
現在的問題是你如何去導航控制器參考,並不怎麼你創造它。 – Wain