我有一种情况,我将UITableView置于编辑模式,当它不处于编辑模式时,它必须执行tableview:didSelectRowAtIndexPath:并且必须推送到UINAvigationController.
现在的问题是如何检查UITableView是否处于编辑模式,以便不应该通过UINavigationController推送它.
iphone uitableview uinavigationcontroller didselectrowatindexpath ios
我已经使用背景图像自定义了导航控制器标题栏,但我真的很难将后退按钮的背景颜色更改为透明,以便与其下方的绿色标题栏匹配.我是iOS开发的新手.任何人都可以建议可以做些什么?
这是我用来更改导航控制器标题栏的代码,以防它有帮助:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] ) {
UIImage *image = [UIImage imageNamed:@"greenbar.png"];
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
// [[UIBarButtonItem appearance] setBackButtonBackgroundImage:image forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
}
//change back button image
}
Run Code Online (Sandbox Code Playgroud)
编辑:做了一些研究后,我设法得到了我想要的东西.以下是更改后退按钮的背景图像的代码:
UIImage *image1 = [UIImage imageNamed:@"back-bt.png"];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:image1 forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)
上面的代码将图像添加到导航控制器中的所有后退按钮.
首先,我使用storyboard创建两个uiviewcontroller:firstviewcontroller和secondviewcontroller.并使用xcode将uinavigationcontroller嵌入到secondviewcontroller中(编辑器 - >嵌入 - >导航控制器).然后,我还想使用segue将值从第一个传递到第二个.有代码:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:@"passValue"])
{
secondViewController *saveViewController = [segue destinationViewController];
[saveViewController setValue:data forKey:@"data"];
}
}
Run Code Online (Sandbox Code Playgroud)
但是会报告错误,日志是: 由于未捕获的异常'NSUnknownKeyException'终止应用程序,原因:'[setValue:forUndefinedKey:]:此类不是密钥数据的密钥值编码兼容.
但是,当我删除导航控制器,我使用Xcode插入它并按代码定义导航栏时,此问题将消失.我猜原因是真正的destinationViewController是navigationcontroller而不是secondviewcontroller.因此,如果我想保留Xcode嵌入的导航控制器,如何解决这个问题呢?
我想隐藏导航栏的后退按钮,这是故事板的一部分,我已经尝试了不同的以下代码片段详细视图按钮似乎没有什么对我有用.
self.navigationItem.hidesBackButton = YES;
self.navigationItem.backBarButtonItem=nil;
Run Code Online (Sandbox Code Playgroud)
PS:我的故事板上还有标签栏和导航栏
有没有什么办法有不同barTintColor的UINavigationController的UINavigationBar不同的推控制器与平滑的色彩过渡动画?
我希望UINavigationBar在UINavigationController推/动画动画期间有一个平滑的色彩动画,理想情况下也是交互式弹出(基于手势的控制器弹出).
我为什么需要这个?我想让导航堆栈中的1个控制器具有不同的色调颜色,指示某个任务的状态(红色/绿色等).
到目前为止我尝试了什么:
viewWillAppear(查看生命周期)方法,但没有办法动画barTintColor(像setBarTintColor:animated:)barTintColor在[UIView animation...]块中,但只是古怪动画(可能)的一些背景层,而不是平滑的颜色过渡的帧.barTintColor在[UIView transitionWithView:...]与块UIViewAnimationOptionTransitionCrossDissolve,但这并不改变动画.在动画持续时间后立即更改为新的色调颜色感谢大家的任何想法和答案
我有一个UIViewController(红色)设置为a的第一个标签,UITabBarController如下面的故事板所示.此视图控制器是一个容器视图控制器,并UINavigationController在其内部加载contentView(红色视图控制器内的白色矩形).

这是我在红色视图控制器中加载导航控制器的代码contentView:
- (void)viewDidLoad
{
[super viewDidLoad];
// instantiate navigation controller
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UINavigationController *navigationVC = [storyboard instantiateViewControllerWithIdentifier:@"N"];
// place navigation controller inside content view
[self addChildViewController:navigationVC];
navigationVC.view.frame = self.containerView.bounds;
[self.containerView addSubview:navigationVC.view];
[navigationVC didMoveToParentViewController:self];
}
Run Code Online (Sandbox Code Playgroud)
根据我所知的视图控制器包含,这应该工作,因为我明确设置导航控制器的框架.但是,如果有足够的单元格tableView超过容器的高度,那么tableView当我向下滚动时,总会有一个条形.为了看到差异,我将tableView's 设置backgroundColor为橙色,将单元格设置backgroundColor为白色.

我怎么摆脱那个橙色的差距tableView呢?
(注意:我没有使用autolayout,我需要一个适用于iOS7 和 iOS6 的解决方案.)
我有一个标签视图控制器,它有一个像这样的按钮,当它被按下时,会出现一个模态:
PostViewController *post = [[PostViewController alloc] init];
// [self.navigationController pushViewController:post animated:YES];
// Presentation
[self presentViewController:post animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
当模态完成后,我想解除它并推送一个新的视图控制器,如下所示:
ProfilesViewController *profile = [[ProfilesViewController alloc] init];
[self.navigationController pushViewController:profile animated:YES];
Run Code Online (Sandbox Code Playgroud)
但我不能在后vc作为它的模态.我该怎么做呢?
当我按下UIViewController使用时,我很难控制键盘行为pushViewController:animated:.从视图中包含一些UITextFields但是视图没有.如果在推动时键盘出现,它会自动与水平推动动画一起自动重新调整.看到幻灯片放映时,从视图中向下滑动是有点刺耳的.
我可以让键盘保持其位置并使用from控制器水平滑出视野吗?我当然已经看到这种情况反过来了,其中控制器有一个呈现的键盘在推动时从左侧滑入.
我希望禁用按下我的标签栏并返回导航层次结构中的根视图的功能,同时还保留导航栏中按钮的此功能.
因此,我希望用户返回根视图的唯一方法是按导航栏中的按钮而不是点击标签栏按钮.
我已经浏览了一下并尝试了几种解决方案,但似乎都没有工作,因为它们禁用了导航栏按钮和标签栏按钮的功能,而不仅仅是标签栏按钮.
谢谢!
uinavigationcontroller uitabbaritem uitabbar ios poptoviewcontroller
我正在构建一个iOS 8应用程序并使用UIPresentationController以自定义方式呈现视图控制器.(请参阅我之前关于此的问题:复制iOS Mail App的撰写功能的样式).
我遇到的问题是,当我呈现控制器时,导航栏以64点高开始,然后在演示完成后跳转/缩小回44.我的猜测是视图控制器意识到它没有覆盖状态栏,因此一旦到达其最终静止位置,它就会自行缩小.我希望导航栏在整个时间内高44点,而不是跳/缩.
下图是视图控制器在演示结束时的样子.这也是我希望它看起来像整个时间.有关如何将导航栏保持在44点整个时间的任何想法?

更新(2015年3月24日):
我前一段时间引用了一篇博文,以找到有关此问题的更多信息.基本上,UINavigationController将其导航栏绘制为64或44点高,具体取决于其视图的框架是否与应用程序的窗口匹配.所以我需要一些方法告诉导航控制器它的最终静止位置不会与窗口对齐,并且导航栏应该被绘制44点高.
http://blog.jaredsinclair.com/post/61507315630/wrestling-with-status-bars-and-navigation-bars-on
objective-c uinavigationcontroller ios uipresentationcontroller
ios ×9
storyboard ×2
uitableview ×2
back-button ×1
cocoa-touch ×1
containment ×1
ios5 ×1
ios6 ×1
ios7 ×1
iphone ×1
objective-c ×1
uikeyboard ×1
uitabbar ×1
uitabbaritem ×1
uitabview ×1
uiview ×1
xcode4.2 ×1