- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
您好,我在 iOS 中以编程方式创建了 UInavigation Controller ,但问题是当我移动到下一个 View Controller 时,我指向同一屏幕。我创建了另一个名称为 InfoView 的 View ,但是当我推送到 InfoView 它显示与我在 ViewController 中创建的按钮相同的屏幕。
#import "AppDelegate.h"
#import "ViewController.h"
@interface AppDelegate ()
{
UINavigationController *navigation;
}
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
navigation = [[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]];
self.window.rootViewController = navigation;
[self.window makeKeyAndVisible];
return YES;
}
#import "ViewController.h"
#import "InfoView.h"
@interface ViewController ()
{
UIButton *RealVideo,*listen,*Readmat,*Look,*DiveIn;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.view.backgroundColor=[UIColor whiteColor];
[self designDeclare];
}
-(void)designDeclare{
RealVideo=[UIButton buttonWithType:UIButtonTypeCustom];
RealVideo.frame=CGRectMake(10,self.view.frame.size.height*0.2, CGRectGetWidth(self.view.frame)-20, CGRectGetHeight(self.view.frame)/7);
[RealVideo addTarget:self action:@selector(real:) forControlEvents:UIControlEventTouchUpInside];
[RealVideo setTitle:@"Real Video" forState:UIControlStateNormal];
RealVideo.backgroundColor=[UIColor colorWithRed:0.744f green:0.000f blue:0.000f alpha:1.00f];
[self.view addSubview:RealVideo];
listen=[UIButton buttonWithType:UIButtonTypeCustom];
listen.frame=CGRectMake(CGRectGetMinX(RealVideo.frame),CGRectGetMaxY(RealVideo.frame)+20, CGRectGetWidth(RealVideo.frame), CGRectGetHeight(RealVideo.frame));
// [listen addTarget:self action:@selector(Listen:) forControlEvents:UIControlEventTouchUpInside];
[listen setTitle:@"Listen" forState:UIControlStateNormal];
listen.backgroundColor=[UIColor purpleColor];
[self.view addSubview:listen];
Readmat=[UIButton buttonWithType:UIButtonTypeCustom];
Readmat.frame=CGRectMake(CGRectGetMinX(RealVideo.frame),CGRectGetMaxY(listen.frame)+20, CGRectGetWidth(RealVideo.frame), CGRectGetHeight(RealVideo.frame));
// [Readmat addTarget:self action:@selector(Listen:) forControlEvents:UIControlEventTouchUpInside];
[Readmat setTitle:@"Reading Material" forState:UIControlStateNormal];
Readmat.backgroundColor=[UIColor colorWithRed:0.000f green:0.412f blue:0.851f alpha:1.00f];
[self.view addSubview:Readmat];
Look=[UIButton buttonWithType:UIButtonTypeCustom];
Look.frame=CGRectMake(CGRectGetMinX(RealVideo.frame),CGRectGetMaxY(Readmat.frame)+20, CGRectGetWidth(RealVideo.frame), CGRectGetHeight(RealVideo.frame));
[Look addTarget:self action:@selector(Look) forControlEvents:UIControlEventTouchUpInside];
[Look setTitle:@"Look" forState:UIControlStateNormal];
Look.backgroundColor=[UIColor colorWithRed:0.400f green:1.000f blue:0.400f alpha:1.00f];
[self.view addSubview:Look];
DiveIn=[UIButton buttonWithType:UIButtonTypeCustom];
DiveIn.frame=CGRectMake(self.view.frame.size.width*0.7,CGRectGetMaxY(Look.frame)+20, CGRectGetWidth(RealVideo.frame)/4,CGRectGetHeight(RealVideo.frame)/1.5);
[DiveIn setTitle:@"Dive In" forState:UIControlStateNormal];
DiveIn.backgroundColor=[UIColor colorWithRed:0.941f green:0.471f blue:0.353f alpha:1.00f];
[self.view addSubview:DiveIn];
}
-(void)real:(id)sender{
}
-(void)Look{
InfoView *infoVC=[[InfoView alloc]init];
[self.navigationController pushViewController:infoVC animated:YES];
}
] 1
最佳答案
导航 Controller 像堆栈一样工作,因此您可以像堆栈在现实世界中的行为一样推送和弹出 View Controller 。将导航 Controller 想象成一堆 View Controller ,因此您实际上不能添加 UIView
,但您想要做的是将 uiview 作为 subview 添加到 View Controller 中并推送该 View 使用一个简单的方法将 Controller 添加到导航 Controller 堆栈中:
[navigationcontroller pushViewController:aViewcontroller];
请通读Apple Documentation了解更多信息。
关于ios - Uinavigation Controller 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33431074/
我已经使用代码(没有 IB 的东西)创建了一个 UItabbarcontroller 和 2 个带有 UITableViews 的 View ,我现在想在顶部添加一个导航栏,其中包括添加和编辑按钮,但
我有一个UIImagePickerController,它允许用户拍照,然后我将其存储在UIImageView中,如下所示: - (void)imagePickerController:(UIImag
这在我看来确实加载了。完全没有显示标题?我有一个 UITabBar,UITabBar 内有一个 UITableView 和 UInavigationBar。 //Creates navigation
我试图将数据传递给 UINavigationController 我知道如何使用常规 View Controller 执行此操作并且它工作正常但是当我尝试使用 UINavigationControll
我刚接触 ipad 开发领域的新手,遇到过 Instapaper 应用程序,我很喜欢这个应用程序的用户界面。 具体来说,alt text http://sbox.smokingapples.com/w
我的 Storyboard中有多个 Storyboard。我已经将firstVC 嵌入到navigationcontroller 中,并通过segues 保持连接到firstvc。其余的 VC 未嵌入
第一个 vc( View Controller )有一个按钮,当我按下它时,我必须转到第二个 vc,它嵌入了标签栏 Controller 。请检查附加图像。 在按钮点击事件中,我这样调用标签栏:- T
我正在通过以下方式加载 UIViewController: -(void)logIn { NewSignInView *viewController = [[[NewSignInView al
我有一个应用程序,它在 Storyboard中利用 UINavigation Controller 来通过两个 UITableView 来访问详细信息 View 。我想跳过第二个 TableView
我将这种颜色用于 UINavigationController 和其他一些 View [UIColor colorWithRed:0.137 green:0.137 blue:0.145 alpha:
您好,我在 iOS 中以编程方式创建了 UInavigation Controller ,但问题是当我移动到下一个 View Controller 时,我指向同一屏幕。我创建了另一个名称为 InfoV
我知道最后我的问题听起来很愚蠢而且很容易解决,但我已经尝试了几个小时让它起作用,但它根本不起作用。 我有一个带有“后退”和“刷新”按钮的 UINavigation 栏。后退按钮工作完美,但我还没有找到
我正在编写 Swift在我的这部分代码中,它应该在选择表格中的单元格时打开一个 View Controller 。 override func tableView(_ tableView: UITab
我正在 Swift 中制作一个应用程序,即使我使用的是导航 Controller ,但有一个特定的点我想呈现一个 View Controller 而不是制作一个 segue 并将 viewContro
我目前很难理解应该使用什么来保存和恢复我的应用状态。 我正在使用 Storyboard并且我有很多 ViewController,我想在应用程序终止时保存所有导航堆栈,以便能够在用户重新启动应用程序时
所以我有这些用于自定义导航栏和项目的图像,它们看起来像这样。目前我设置了自定义导航栏,但是我不知道如何将默认的“后退”按钮更改为下面的后退按钮图片,这就是我想知道的?任何帮助将不胜感激。注意:我正在使
我已经构建了一个基于导航的应用程序,但现在我已深入代码,我决定实际上最好只使用 UIToolbar (只需要模态视图,而不是钻取)下降)。但是,摆脱导航内容并用工具栏替换它给我带来了各种悲伤.....
好吧,目前我有一个导航 Controller ,带有一个可以让用户登录的右键。 但是我想将登录按钮更改为单击后注销,并且此注销按钮将调用不同的 IBAction。 帮助可视化这一点。 默认情况下,我的
我正在制作一个具有 UITabBar 和 UINavigationConroller 的应用程序。当我在应用程序周围单击时,屏幕顶部的导航项会出现,屏幕底部的 UITabBar 也会出现。 但是当我点
我想创建一个 UINavigationController 的子类,这样我就可以在我的应用程序中设置特定的样式 - 例如,白色字体和蓝色背景。 我用的是swift,所以我写了这段代码: import
我是一名优秀的程序员,十分优秀!