我正在处理UINavigationControllers我的应用程序,所有这些都由UITabBarController. 一切工作正常,直到我的控制器落入自动生成的“更多”选项卡。
我在简单的示例中重现了该问题。难道我做错了什么?我想不通。
感谢您的帮助。
#import <UIKit/UIKit.h>
@interface testAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate>
{
UIWindow *窗口;
UITabBarController *tabBarController;
}
@property(非原子,保留)IBOutlet UIWindow *window;
@property(非原子,保留)IBOutlet UITabBarController *tabBarController;
@结尾
@实现testAppDelegate
@synthesize窗口,tabBarController;
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
UINavigationController *ctrl1 = [[[UINavigationController alloc] initWithNibName:nil bundle: nil] autorelease];
ctrl1.tabBarItem = [[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFeatured tag:1] autorelease];
UINavigationController *ctrl2 = [[[UINavigationController alloc] initWithNibName:nil bundle: nil] autorelease];
ctrl2.tabBarItem = [[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:2] autorelease];
UINavigationController *ctrl3 = [[[UINavigationController alloc] initWithNibName:nil bundle: … 我想在添加子视图时禁用导航栏,并在删除子视图后再次启用它。怎么做。显示操作表时的类似操作。
uinavigationbar uinavigationcontroller ios childviewcontroller ios7
简短问题:

推动视图控制器时如何去除蓝色圆圈中的阴影?
长问题:
我的应用程序就像 Facebook。有新闻源视图、详细帖子视图和页面视图。这是我的界面生成器中的内容:
这HomeViewController是 NewsFeed 视图,DetailPostViewController是详细信息页面视图,FirstViewController是页面视图。嵌入HomeViewController到 a 中,UINavigationController而 又嵌入到 a 中UITabBarController。
FirstViewController当我从 推到时,这是完全正常的DetailPostViewController。(注意,我没有使用segue来推送,而是使用storyboard ID)

但是当我从 推DetailPostViewController到时FirstViewController,导航栏上有一个奇怪的阴影,就像重叠一样。但我不想要这样。(不使用segue,而是使用storyboard ID)

这是我的代码FirstViewController
var vc = self.storyboard?.instantiateViewControllerWithIdentifier("PageViewController") as! FirstViewController
self.navigationController?.pushViewController(vc, animated: true)
Run Code Online (Sandbox Code Playgroud)
如何使推送DetailPostViewController看起来FirstViewController正常?我尝试使用 segue 但没有成功。尝试了这么久但仍然没有运气。谢谢。
我有一个视图控制器FromViewController,我希望它呈现ToViewController一个自定义过渡。我已经UIViewControllerAnimatedTransitioning为 to- 和 from-转换实现了,当我呈现和关闭ToViewController.
但是,如果 myFromViewController包含在 a 中,UINavigationController当我关闭ToViewController.
这是UIViewControllerAnimatedTransitioning解雇时的代码:
- (void)animateTransition:(nonnull id<UIViewControllerContextTransitioning>)transitionContext {
self.toViewController = (ToViewController *)
[transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UINavigationController *navigationController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
self.fromViewController = (FromViewController *)navigationController.topViewController;
self.containerView = transitionContext.containerView;
[self.containerView insertSubview:self.fromViewController.view belowSubview:self.toViewController.view];
// My animations go here
// In the animation completion block I call:
[transitionContext completeTransition:!transitionContext.transitionWasCancelled]; // this is when my screen goes black
}
Run Code Online (Sandbox Code Playgroud)
我已经检查了该应用程序,并且在解雇后似乎既不存在UINavigationController也不FromViewController在视图层次结构中。
uiviewcontroller uinavigationcontroller ios presentviewcontroller
单击 SearchBar 时出现多条白线。
同时使用TabBarController和彩色条NavigationController时会发生这种情况,但是
我使用以下代码行在AppDelegate 中设置导航颜色:
UINavigationBar.appearance().barTintColor = UIColor(rgb: 0x0277BD)
UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white]
Run Code Online (Sandbox Code Playgroud)
我使用以下方法在SearchViewController 中设置了 UISearchController :
let searchController = UISearchController(searchResultsController: nil)
override func viewDidLoad() {
super.viewDidLoad()
// Setup the Search Controller
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Search Events"
searchController.searchBar.tintColor = .white
navigationItem.searchController = searchController
definesPresentationContext = true
}
Run Code Online (Sandbox Code Playgroud)
知道发生了什么吗?
我有一个tabBar. 它的每个选项卡ViewControllers都嵌入在各自的NavigationControllers.
等级制度:
Tabbarcontroller--> NavigationController--> VC1 --> VC2 -->...VCn(对于tab1)
当我单击推送通知时,我必须重定向到其中一个视图控制器说 VC2。我使用的代码如下。
let navigationController = UINavigationController()
let storyboard = UIStoryboard.init(name: "Main", bundle: Bundle.main)
if let chatViewController = storyboard.instantiateViewController(withIdentifier: "chatViewController") as? ChatViewController {
navigationController.viewControllers = [chatViewController]
window?.rootViewController = navigationController
}
Run Code Online (Sandbox Code Playgroud)
通过使用它,我被重定向到相应的ViewController. 但是,我无法回到tabBar. 那么是否有可能以允许我返回标签栏的方式重定向,从而提供与 UI 中相同的层次结构?
编辑:
下图显示了我的布局。
我想完成以下工作:
当用户点击推送通知时,应用程序应被定向到 VC-B。*如果 VC-B 已经在导航堆栈的顶部,它不应该为 VC-B 创建新对象并添加到导航堆栈。
如果应用程序已终止并且用户点击通知,则应打开 VC-B。
为了确定应用程序是否已终止,我设置了一个标志:
func applicationWillTerminate(_ application: UIApplication) {
UserDefaults.standard.set(true, forKey: UserDefaultsKey.isTerminated)
}
Run Code Online (Sandbox Code Playgroud)
该标志在 didFinishLaunchingWithOptions 函数结束时设置为 false。 …
uitabbarcontroller uinavigationcontroller push-notification ios swift
我有一个 UINavigation 控制器,用于推送或弹出视图。在初始视图控制器中,我想隐藏导航栏底部 1 像素的阴影。所以我这里是代码。
func setup(){
if #available(iOS 11.0, *) {
self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationController?.navigationItem.largeTitleDisplayMode = .always
} else {
// Fallback on earlier versions
}
self.navigationBar.isTranslucent = true
self.navigationBar.clipsToBounds = true
self.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationBar.shadowImage = UIImage()
self.navigationBar.tintColor = UIColor(hexString: "#373839")
self.navigationBar.backgroundColor = UIColor.white
}
Run Code Online (Sandbox Code Playgroud)
但是当我推送到第二个 View 控制器时,导航栏的阴影甚至隐藏在其中。
在父视图控制器中设置导航栏的属性会影响从那里推送的所有控制器中的属性吗?我认为导航栏特定于视图控制器,导航控制器为每个推送的视图创建一个新的导航栏。
有人可以帮助我理解这一点,以及如何在导航栏上仅显示 1 个像素的阴影以显示 1 个视图。
我正在尝试在我的应用程序中实现暗模式切换 - 这将涉及UIViewController在屏幕上已经可见时将导航栏颜色切换为黑色。我知道如何通过设置来做到这一点
UINavigationBar.appearance().barTintColor = .black
UINavigationBar.appearance().tintColor = .white
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
UINavigationBar.appearance().isTranslucent = false
Run Code Online (Sandbox Code Playgroud)
但是,在 AppDelegate 中,这在这种情况下不起作用,因为它需要动态完成。
我也试过 navigationController?.navigationBar.barTintColor = UIColor.white但这也不起作用。
更新:
我认为很多回答都与这个问题的目的混淆了 - 这与刚刚发布的 iOS13 暗模式完全无关 - 这是我想添加到我的应用程序的独立暗模式功能(类似于其他Messenger 等应用程序在 iOS 13 发布之前在应用程序内提供暗模式)。我需要做的是在 UINavigationBar 已经显示在屏幕上之后动态更新它的颜色,就像我可以通过执行更改视图的背景颜色一样,view.backgroundColor = .white这将在屏幕上实时更新颜色。
uiviewcontroller uinavigationcontroller uinavigationitem ios swift
我目前正在制作一个具有底部功能的应用程序,当用户点击对话框内的图标(图像视图)时,片段将显示出来。我的问题是我无法导航到片段 b 并且它返回了这个错误
这是我的主页片段,活动启动时第一个开始的片段
public class HomeFrag extends Fragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home, container, false);
ImageView buttonOpenSheet = view.findViewById(R.id.buttonopensheet);
buttonOpenSheet.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
BottomSheetDialog bottomsheet = new BottomSheetDialog();
bottomsheet.show(getFragmentManager(), "bottomsheet");
}
});
return view;
}}
Run Code Online (Sandbox Code Playgroud)
底部对话框.java
public class BottomSheetDialog extends BottomSheetDialogFragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final View view = …Run Code Online (Sandbox Code Playgroud) android uinavigationcontroller navigationcontroller android-jetpack
这就是我的应用程序中的内容
一切都按预期正常工作,但有一件事我无法弄清楚为什么会发生。
当我转到 Fragment #2 将数据插入或更新到 Room Database 然后使用(顶部或底部)后退按钮返回 Fragment #1 时,Fragment #1 不会重新加载并且数据不会更改(更新),直到我重新加载数据.
在其他情况下,当我在同一片段插入或更新数据时,列表会立即更改。
我必须在同一个片段上进行插入和更新操作吗?
我不能在其他片段上这样做吗,当我回到列表片段时,我发现数据已更新?
请记住,它就像我希望的那样工作,但在某些时候我真的不知道它不再存在了!!
android uinavigationcontroller android-fragments android-room android-livedata