我正在处理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 但没有成功。尝试了这么久但仍然没有运气。谢谢。
我正在尝试创建一个自定义UINavigationBar类,然后使用将其设置为我的 NavigationBar 的Storyboard类。UINavigationController
这是我的班级的代码UINavigationBar:
class CustomNavBar: UINavigationBar {
override func drawRect(rect: CGRect) {
super.drawRect(rect)
// Drawing code
self.backgroundColor = UIColor.orangeColor()
let myLabel = UILabel(frame: CGRect(x: 0, y: 4, width: 600, height: 36))
myLabel.backgroundColor = UIColor.purpleColor()
myLabel.textColor = UIColor.yellowColor()
myLabel.text = "Custom NavBar!"
self.addSubview(myLabel)
}
}
Run Code Online (Sandbox Code Playgroud)
然后,在 Interface Builder 中,我使用 将Identity Inspector其设置为NavigationBar我的UINavigationController.
当我运行该应用程序时 - 它冻结了。它挂起LaunchScreen.xib并且不执行任何操作。
为什么要这么做?这样做的正确方法是什么?
有时,当用户返回到上一个时UIViewController,我想做点什么。
如果用户单击 中的后退按钮UINavigationBar,我可以捕获该事件。
但如果他们使用向后滑动手势返回,我将无法响应更改。
那么滑动返回手势有回调吗?
目前我只能通过以下方式在我的应用程序中禁用此类页面
interactivePopGestureRecognizer.enabled = NO;
Run Code Online (Sandbox Code Playgroud) 是否可以使用UISearchController而不SearchBar显示在 中Navigation Controller?我基本上希望SearchBar保留在屏幕上并在其下方显示 TableView:
我想做的是:我UITableViewController在故事板上创建了一个并将其链接到自定义NPTableViewController类。然后我这样做了:
let resultsTable = storyboard!.instantiateViewController(withIdentifier: "LocationSearch") as! NPTableViewController
searchController = UISearchController(searchResultsController: resultsTable)
searchController?.searchResultsUpdater = resultsTable
let searchBar = searchController!.searchBar
searchBar.sizeToFit()
searchBar.placeholder = "Search for places"
searchBar.frame.origin.y = 100.0
self.view.addSubview(searchBar)
Run Code Online (Sandbox Code Playgroud)
现在,当我运行它时,会searchBar显示 ,但是当我单击它时,背景会变暗,searchBar消失,我的resultsTable也不显示。
iphone uinavigationcontroller uisearchbar swift uisearchcontroller
我正在尝试在我的应用程序中实现暗模式切换 - 这将涉及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
我有一个UINavigationController它的navigationBar配置为prefersLargeTitles = true和isTranslucent = false。
导航堆栈中的第一个视图控制器是 a ,UITableViewVontroller其navigationItem配置为largeTitleDisplayMode = .always。如果我推送另一个视图控制器并largeTitleDisplayMode = .never再次弹出它,则第一个视图控制器处于大标题折叠的状态。我必须向上滚动才能再次放大标题。
这是iOS 14故意的行为吗?有没有办法恢复大标题?
isTranslucent编辑:我刚刚意识到,该行为与导航栏的属性相关。
ios ×5
swift ×4
iphone ×3
android ×2
android-room ×1
cocoa-touch ×1
ios7 ×1
objective-c ×1
subclass ×1
uikit ×1
uisearchbar ×1