新的 UIView 未加载
我有一个 TabController 视图设置,我正在尝试在当前选项卡中加载新视图。该视图将根据 UIAlertView 中的选择进行加载。
因此,我有以下代码尝试这样做:
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{
// Yes Button
if (buttonIndex == 0) {
NSLog(@"%@ Pressed", [alertView buttonTitleAtIndex:0]);
user = [[UserInfo alloc] initWithNibName:@"UserInfo" bundle:nil];
[self.navigationController pushViewController:user animated:YES];
[user release];
}
// Don't show again Button
if (buttonIndex == 1) {
NSLog(@"%@ Pressed", [alertView buttonTitleAtIndex:1]);
}
// No Button
if (buttonIndex == 2) {
NSLog(@"%@ Pressed", [alertView buttonTitleAtIndex:2]);
}
}
“是”块打印到控制台,但是新视图不会加载。 User 是 UserInfo 的实例,而 UserInfo 又是 UIViewController 的子类。 Nib UserInfo 已创建并且是项目的一部分。
我缺少什么?
I have a TabController View setup and I am attempting to load a new view in the current tab. This view would be loaded depending on a selection from a UIAlertView.
As such I have this code attempting to do so:
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{
// Yes Button
if (buttonIndex == 0) {
NSLog(@"%@ Pressed", [alertView buttonTitleAtIndex:0]);
user = [[UserInfo alloc] initWithNibName:@"UserInfo" bundle:nil];
[self.navigationController pushViewController:user animated:YES];
[user release];
}
// Don't show again Button
if (buttonIndex == 1) {
NSLog(@"%@ Pressed", [alertView buttonTitleAtIndex:1]);
}
// No Button
if (buttonIndex == 2) {
NSLog(@"%@ Pressed", [alertView buttonTitleAtIndex:2]);
}
}
The Yes block prints out to the console, however the new view does not load. User is an instance of UserInfo, which in turn is a subclass of UIViewController. The Nib UserInfo is created and is part of the project.
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这两行是不必要的:
但这一行是:
您如何设置标签栏控制器?您是否将此视图放置在 UINavigationController 中,然后将该导航控制器添加到 TabBarController 中?
请查看 iOS 视图控制器编程指南(特别是组合 ViewController 接口部分)并验证您是否正确嵌套了这些视图。
These two lines are unnecessary:
But this one is:
How are you setting up your tab bar controller? Have you placed this view inside of a UINavigationController then added that navigation controller to the TabBarController?
Please review the View Controller Programming Guide for iOS (specifically the Combined ViewController Interfaces section) and verify you are nesting these views correctly.
user 是全局变量吗?我通常会看到类似的东西
UserInfo *user = [[UserInfo alloc] initWithNibName:@“UserInfo”bundle:nil];
作为模式。由于导航控制器实际上将成为视图的主要所有者
Is user a global variable? I usually see something like
UserInfo *user = [[UserInfo alloc] initWithNibName:@"UserInfo" bundle:nil];
as the pattern. Since the navigation controller is really going to be the main owner of the view