Ios placeholer中的评论现在显示出来

Ios placeholer中的评论现在显示出来,ios,textview,placeholder,Ios,Textview,Placeholder,我的部分代码: commentTextView = [[GCPlaceholderTextView alloc] initWithFrame:CGRectMake(5.0f, 0.0f, 260.0f, 24.0f)]; [commentTextView setBackgroundColor:[UIColor clearColor]]; [commentTextView setTextColor:[UIColor whiteColor]]; [[commentTextView layer] se

我的部分代码:

commentTextView = [[GCPlaceholderTextView alloc] initWithFrame:CGRectMake(5.0f, 0.0f, 260.0f, 24.0f)];
[commentTextView setBackgroundColor:[UIColor clearColor]];
[commentTextView setTextColor:[UIColor whiteColor]];
[[commentTextView layer] setCornerRadius:2.0f];
[[commentTextView layer] setMasksToBounds:YES];
[commentTextView setDelegate:self];

[commentTextView setPlaceholder:NSLocalizedString(@"Add a comment ... ", nil)];//Add a comment is not showing and I dont know why.

[commentTextView setPlaceholderColor:[UIColor whiteColor]];
[commentTextView setTintColor:[UIColor colorWithRed:0.243 green:0.847 blue:0.769 alpha:1]];
[commentTextView setAutocorrectionType:UITextAutocorrectionTypeNo];
[inputAccessoryContentView addSubview:commentTextView];
我使用navigationcontroller作为我的根控制器。但是如果我使用viewcontroller作为我的根控制器,则占位符工作得很好。而GCPlaceholerTextView是UITextView

这是我的AppDelegate中的代码

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// works well in VC
 /*
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc]init];
self.window.rootViewController = self.viewController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
 */
// doesn't work well in nav
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
self.window.rootViewController = navController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];

return YES;
}

请解释什么有效,什么无效,以及如何创建实例。[commentTextView setPlaceholder:NSLocalizedString(@“添加注释…”,nil)];只有这个句子不起作用