我有两种方法可以从一个视图控制器跳转到另一个视图控制器
对于presentViewController
[self presentModalViewController:view animated:YES];
Run Code Online (Sandbox Code Playgroud)
对于pushViewControlle应该使用
[self.navigationController pushViewController:view animated:YES];
Run Code Online (Sandbox Code Playgroud)
哪种方法是最好的方法?
哪个会导致更多的内存泄漏?
如果我们的设计是这样的,则使用哪一个
Introduction view (bunch of slides )-> login -> signUp-> HomeActivityScreen-> Then Bunch of tab bar in it
Run Code Online (Sandbox Code Playgroud) xcode objective-c uinavigationcontroller presentmodalviewcontroller ios
private func setTitle(title:String, subtitle:String, animate: Bool) -> UIView {
let titleLabel = UILabel(frame: CGRect(x:0, y:-5, width:0, height:0))
titleLabel.backgroundColor = UIColor.clear
titleLabel.textColor = UIColor.gray
titleLabel.font = UIFont.boldSystemFont(ofSize: 15)
titleLabel.text = title
titleLabel.adjustsFontSizeToFitWidth = true
let subtitleLabel = UILabel(frame: CGRect(x:0, y:18, width:0, height:0))
subtitleLabel.backgroundColor = UIColor.clear
subtitleLabel.textColor = UIColor.black
subtitleLabel.font = UIFont.systemFont(ofSize: 12)
subtitleLabel.text = subtitle
subtitleLabel.adjustsFontSizeToFitWidth = true
let titleView = UIView(frame: CGRect(x:0, y:0, width:max(titleLabel.frame.size.width, subtitleLabel.frame.size.width), height:30))
let titleViewTapGesture = UITapGestureRecognizer(target: self, action: #selector(titleViewTapped(sender:)))
titleView.addGestureRecognizer(titleViewTapGesture)
titleView.addSubview(titleLabel)
if animate{
subtitleLabel.alpha = 0.0 …Run Code Online (Sandbox Code Playgroud) 我已将 Xcode 更新为 13,后来我的旧项目导航中的文字和选项卡栏颜色更改为透明。
我的代码是
[[UINavigationBar appearance] setBarTintColor:[UIColor AppThemeColour]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTranslucent:NO];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
Run Code Online (Sandbox Code Playgroud)
我尝试添加背景颜色,但导航栏的标题和图像没有出现。
self.navigationController.navigationBar.backgroundColor = [UIColor bOneAppThemeColor];
[[UINavigationBar appearance] setBarTintColor:[UIColor AppThemeColour]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTranslucent:NO];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
Run Code Online (Sandbox Code Playgroud)
我已经研究了下面的链接,但我无法在 Objective C 中实现它
xcode objective-c uinavigationbar uinavigationcontroller ios
我不确定我的应用程序发生了什么变化。由于某种原因,最近当我尝试开发它时,我的应用程序上的导航栏开始消失,然后当我向下滚动时重新出现。这是演示这一点的屏幕截图。
是什么让我的导航栏消失了?
应用程序打开到左侧的屏幕截图,然后向下滚动以显示右侧的屏幕截图。
这是一个全新的导航控制器,我在 Storyboard 上设置并在初始视图控制器中设置。新控制器的实际 swift 代码如下。
import UIKit
class NewsViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections …Run Code Online (Sandbox Code Playgroud) 我想在点击按钮后显示导航控制器.每个教程都假定导航控制器将是第一个屏幕,因此它将其链接到App Delegate,但App委托仅出现在MainWindow.xib中.你们如何为不同于MainWindow的视图添加导航控制器?
谢谢!
我在视图上有一个按钮.当我点击它时,它应该加载另一个视图,一个带有novigation控制器.到目前为止,我已经有了这个,按钮调用这个方法:
-(IBAction)loadOptionsView:(id)sender {
if (self.optionsRootController == nil) {
//optionsRootController is declared as: UINavigationController *optionsRootController;
optionsRootController = [[UINavigationController alloc] init];
//Options is a UIViewController
Options *myOptions = [[Options alloc] initWithNibName:@"OptionsMenu" bundle:nil];
[optionsRootController pushViewController:myOptions animated:NO];
[myOptions release];
}
[self.view addSubview:optionsRootController.view];
}
Run Code Online (Sandbox Code Playgroud)
单击按钮时会发生什么,它会在当前屏幕顶部加载xib文件OptionsMenu,但状态栏大小顶部有一个间隙,所以我可以看到下面的视图.有帮助吗?加载包含导航控制器的新视图的正确方法是什么?
谢谢你们!
嘿伙计们,就像问题所说,我试图在不使用presentModalViewController或pushViewController的情况下在UIDatePicker中滑动,然后隐藏应用程序的主UITabBar.现在,我将UIDatePicker子视图与导航栏上的几个按钮添加到临时UIViewController,并使用该临时控制器作为根初始化UINavigationController.我将此导航控制器作为子视图添加到self.navigationController.tabBarController以尝试覆盖UITabBar,但是当我将UITabBar设置为隐藏时,我看到的只有白色,没有UIDatePicker可见.有什么建议?
注意:我的理由是我无法想出一种方法来使用带有小于屏幕的视图的presentModalViewController.
我知道,这很奇怪,但即使您将hidesBackButton声明为与您的视图关联的UINavigationItem为YES,您也可以返回只是触摸本来是后退按钮的区域.
分享我的解决方案......(更多内容)
在我的applicationDidFinishLaunching中,我设置了一个UINavigationController:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
navController = [[UINavigationController alloc] init];
[[navController navigationBar] setFrame:CGRectMake(0.0,0.0,320.0,20.0)];
...
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我正在尝试使导航控制器的高度为20px.但是,这不起作用.我认为setFrame必须是正确的函数,但我没有在正确的位置调用它.我意识到关于SO的其他问题与我的相似,但我认为如果它响应setFrame,设置navigationBar高度应该是正确的......对吗?
还有,谁知道navigationBar的默认高度?
谢谢!
我有一个视图,有时看起来像uinavigationcontroller的推送视图,有时就像一个标签栏项目的初始视图.
界面上有一个"保存"按钮,我想让视图在被推到屏幕上时弹回到上一个视图,当它作为标签栏选择屏幕的一部分显示时什么也不做.
在伪代码中,我想我想要做的是:
if view-has-been-pushed, then pop back, else do nothing
Run Code Online (Sandbox Code Playgroud)
如何判断视图是否被推送?
iphone ×6
ios ×4
objective-c ×4
xcode ×3
swift ×2
cocoa-touch ×1
storyboard ×1
uilabel ×1
uitabbar ×1
uiview ×1