我有一个UINavigationController.我必须从a弹出一个视图UINavigationController并用另一个视图替换它.我们如何搜索UIViewController对象并用另一个替换它?
当我打印
NSMutableArray *allViewControllers = [NSMutableArray arrayWithArray: myDelegate.navigationController.viewControllers];
Run Code Online (Sandbox Code Playgroud)
我试过了..
[allViewControllers removeObjectIdenticalTo: @"NonLogginedViewController"];
[allViewControllers removeObjectIdenticalTo: myDelegate.nonLogginedViewController];
myDelegate.navigationController.viewControllers = allViewControllers;
Run Code Online (Sandbox Code Playgroud)
但它并没有更新的UINavigationController堆栈..我不知道如何使用removeObjectIdenticalTo与UINavigationController堆栈..
请帮我 ..
iphone stack objective-c nsmutablearray uinavigationcontroller
我有一个UIViewController(父),presentModalViewController用另一个UIViewController(子)调用viewDidLoad.
如果父级没有UINavigationController,则不presentModalViewController执行任何操作.如果它有一个UINavigationController,则按预期presentModalViewController显示子项.
这是标准的行为presentModalViewController还是在这里有其他的东西在玩?
iphone modal-dialog uiviewcontroller uinavigationcontroller ios
我目前有以下代码从另一个视图加载UIWebView.无论如何我现在有一个关闭按钮?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIWebView *webView=[[UIWebView alloc] initWithFrame:CGRectMake(0,0,320,480)];
[self.view addSubview:webView];
NSURLRequest *urlRequest;
NSURL *urlforWebView;
urlforWebView=[NSURL URLWithString:@"http://www.google.com"];
urlRequest=[NSURLRequest requestWithURL:urlforWebView];
[webView loadRequest:urlRequest];
}
Run Code Online (Sandbox Code Playgroud)
我将加载使用jquery mobile构建的页面,因此页面内的关闭按钮也可以正常工作.但在导航栏上是理想的.顺便说一句,我的应用程序不具有UINavigationBar的
我在周末期间未能解决这个问题...我认为对Objective-C内存管理有很好的了解,但是这个很难解决.
总结一下上下文:我有一个吸引人的UIViewController,我在我的navigationcontroller中推送.这个UIViewController包含一个UIScrollView(在IB中创建).在UIViewController viewDidLoad()函数中,我添加了一个背景PDF(在UIview层的CATiledLayer子层中).
问题是,当我从导航控制器弹出UIViewController时,应用程序崩溃了.
使用Zombies工具和NSZombieLevel表明这是因为UIViewController被过度释放.
这是UIViewController:
@interface PlanViewController : UIViewController <UIScrollViewDelegate> {
UIScrollView *panelScrollView;
UIView *myContentView;
CGPDFDocumentRef myDocumentRef;
CGPDFPageRef myPageRef;
}
@property (nonatomic, retain) IBOutlet UIScrollView *panelScrollView;
@property (nonatomic, retain) UIView *myContentView;
@end
@implementation PlanViewController
@synthesize panelScrollView;
@synthesize myContentView;
- (void)viewDidLoad {
[self setTitle:@"Plan"];
myDocumentRef = CGPDFDocumentCreateWithURL((CFURLRef)[[NSBundle mainBundle] URLForResource:@"salonMap" withExtension:@"pdf"]);
myPageRef = CGPDFDocumentGetPage(myDocumentRef, 1);
CGRect pageRect = CGRectIntegral(CGPDFPageGetBoxRect(myPageRef, kCGPDFCropBox));
CATiledLayer *tiledLayer = [[CATiledLayer alloc] init];
[tiledLayer setDelegate:self];
[tiledLayer setTileSize:CGSizeMake(1024.0, 1024.0)];
[tiledLayer setLevelsOfDetail:4];
[tiledLayer setLevelsOfDetailBias:8];
[tiledLayer setFrame:pageRect]; …Run Code Online (Sandbox Code Playgroud) iphone cocoa-touch memory-management release-management uinavigationcontroller
为什么didFinishLaunchingWithOptions方法中需要以下行?
self.window.rootViewController = self.navigationController;
Run Code Online (Sandbox Code Playgroud)
也就是说,在Interface Builder中,MainWindow XIB中已经有导航控制器,它的导航栏和RootViewController在它的层次结构中.
整个方法的副本供参考:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// Add the navigation controller's view to the window and display.
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
Run Code Online (Sandbox Code Playgroud) 我对这个委托消息感到困惑.我在PopupViewController中有一个导航控制器.当我推送一个新的viewController时,我不知道它被当前显示的viewController是什么,在新的一个被推送之前...
我已经尝试过获取navigationController.topViewController和navigationController.visibleViewContrller,但是它们都总是等于它将被推送的viewController ...看起来我在视图被推送后收到了消息
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
UIViewController *currentViewController = navigationController.topViewController;
if(currentViewController == viewController){
/// THIS IF STATEMENT IS ALWAYS TRUE
}
}
Run Code Online (Sandbox Code Playgroud)
有没有人偶然发现类似的东西?
我有一个导航控制器,左侧是自定义后退按钮.我以编程方式执行此操作,因此这不是自动布局问题.我的问题是导航控制器标题没有居中,它是在屏幕的右侧.我记得在这一段时间内看到了一个修复,将一些类型的固定空间设置为正确的条形按钮项目,但我现在似乎无法找到类似的东西.
有人可以告诉我如何将导航控制器标题设置为居中,如果标题对于其空间太大,请设置导航栏标题以修复其字体大小以适应标题空间的宽度.这一切都需要以编程方式完成,谢谢!
objective-c uinavigationbar uinavigationcontroller uinavigationitem ios
我正在尝试返回到以前的视图控制器,但我正在遇到的问题(据我所知)不应该发生.
我正在尝试做的简短描述:我有4个视图控制器:A,B,C和D.基本的UI流程是A - > B - > C - > D.在C完成工作后,我想要返回B.
我的代码:
let viewControllerArray = self.navigationController?.viewControllers
for(var i=0;i<viewControllerArray?.count;i++){
if(viewControllerArray![i].isKindOfClass(InventoryListViewController)){
self.navigationController?.popToViewController(viewControllerArray![i], animated: true)
}
}
Run Code Online (Sandbox Code Playgroud)
如果B仍然存在于navigationcontroller的堆栈中,这一切都可以正常工作.如果B已从堆栈中删除(由于与内存相关的原因),它会让我尝试弹出一个不存在错误的视图控制器(显然).我很困惑的是,如果B不再存在于堆栈中,那么If语句是否应该阻止调用popToViewController方法?
我正在构建一个待办事项列表应用程序,以便使用tableViews和delegates进行更多练习.我已将我的主tableViewController嵌入到导航控制器中,并且我创建了两个额外的视图控制器,一个用于添加任务,另一个用于编辑任务.当我尝试将一个条形按钮项添加到其中一个附加视图控制器(完成,垃圾等)时,Xcode将项目放在屏幕底部的标签栏中,当我运行应用程序时,这些项目不是可见.我已经改变了我正在使用的设备类型,完全重新启动了Xcode,我无法弄清楚为什么会发生这种情况.我在下面添加了一个截图,这里是一个回购链接.任何想法为什么会这样?
我正在设计一个从右到左的应用程序。通过使用以下代码行,我将所有内容设置为rtl:
UIView.appearance().semanticContentAttribute = .forceRightToLeft
Run Code Online (Sandbox Code Playgroud)
并且对所有期望我的导航控制器具有交互弹出手势的东西来说都是正确的。正确的方向:
但是当我要使用弹出手势(从左边缘向右边缘滑动)时,从相反的一侧可以看到该视图。
我该如何更改?
我尝试将边缘更改为.right,但是禁用了手势识别器:
let gesture = interactivePopGestureRecognizer as! UIScreenEdgePanGestureRecognizer
gesture.edges = .right
Run Code Online (Sandbox Code Playgroud) ios ×7
iphone ×6
cocoa-touch ×2
objective-c ×2
swift ×2
modal-dialog ×1
rootview ×1
stack ×1
swift3 ×1
uitableview ×1
uiwebview ×1
xcode ×1