Trong lớp con của tôi về NSObject
Tôi muốn gọi cái gì đó nhưGọi presentModalViewController từ NSObject lớp
[[self navController] presentModalViewController:myView animated:YES];
Nhưng không ai trong số cố gắng của tôi đã thành công. Làm thế nào tôi có thể gọi một chế độ xem phương thức nếu tôi không ở trong một lớp con của UIViewController
?
Giải pháp:
#import "myProjectNameAppDelegate.h"
// ...
MyViewController *myView = [[MyViewController alloc] init];
myProjectNameAppDelegate *appDelegate = (myProjectNameAppDelegate *)[[UIApplication sharedApplication] delegate];
[[appDelegate navController] presentModalViewController:myView animated:YES];
Tôi có thuộc tính trong 'AppDelegate' được gọi là" navController ". Tại sao tôi không thể truy cập '\t \t [[[UIApplication sharedApplication] navController] presentModalViewController: myView hoạt hình: YES]; 'Tôi có phải khai báo một thuộc tính khác và đặt thuộc tính này thành' self' trong 'didFinishLaunchingWithOptions:'? – testing
Bạn sẽ có thể truy cập trực tiếp khi bạn dán, nó có hoạt động không? – jv42
Không, tôi nhận được "'UIApplication' có thể không trả lời '-navController'". Với 'delegate' tôi nhận được" '-navController' không tìm thấy trong giao thức (s) " – testing