我试图通过使用删除uinavigationcontroller的backbutton
appdelegate.navigationController.navigationItem.hidesBackButton=YES;
Run Code Online (Sandbox Code Playgroud)
但是在将新的viewcontroller推入导航堆栈后,它不会删除后退按钮.如何隐藏它?
我的应用程序有一个带导航栏的tabBar,
tabBar正在显示并正常工作,但是当我想要转到其中一个选项卡中的另一个页面时,它不会加载新页面,
这是我的应用代表
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
StartViewController *startViewControllerView = [[[StartViewController alloc] init] autorelease]; //ojo recomendado por apple!!!
PhotosViewController* PhotosViewController_ = [[[PhotosViewController alloc] init] autorelease];
VideosViewController* VideosViewController_ = [[[VideosViewController alloc] init] autorelease];
SocialViewController* SocialViewController_ = [[[SocialViewController alloc] init] autorelease];
NSArray* controllers = [NSArray arrayWithObjects: startViewControllerView, VideosViewController_, PhotosViewController_, SocialViewController_, nil];
self.tabBarController.viewControllers = controllers;
self.pagesNavigation = [[[UINavigationController alloc] initWithRootViewController:startViewControllerView] autorelease];
self.pagesNavigation.navigationBarHidden = NO;
[self tabBarConfig];
[self.tabBarController setViewControllers:controllers animated:YES];
[self.window addSubview:self.pagesNavigation.view];
self.window.rootViewController = self.tabBarController;
//self.window …Run Code Online (Sandbox Code Playgroud) iphone uitabbarcontroller uinavigationcontroller pushviewcontroller ios
我想编写集成应用程序测试来测试完整的CRUD操作.我有一个表视图列出所有对象.用户可以单击"添加"按钮推送新的详细视图控制器以添加新对象; 他们可以单击现有对象来推送详细视图控制器以重命名对象; 他们还可以从列表中删除对象.
我很高兴尝试使用OCUnit测试我的应用程序.但是,我遇到了一些奇怪的错误.我正在使用UITabBarController + UINavigationController.我的UINavigationController中有超过3级的pushViewController.如果我使用[self.navigationController pushViewController:viewController animated:YES]测试代码,它主要使用两个警告:
nested push animation can result in corrupted navigation bar
nested pop animation can result in corrupted navigation bar
Run Code Online (Sandbox Code Playgroud)
我注意到没有调用viewDidAppear因此警告.
然后我尝试通过更改动画来解决方法:是动画:否.警告消失了.但是,我遇到了另一个根本没有调用viewDidLoad的bug.因此视图不会从NIB文件加载,并且所有IB控件都是零.如果我将动画设置为YES,则不是这种情况.
这是我用来获取UINavigationController中根视图控制器句柄的代码.
app = (MyAppDelegate*) [[UIApplication sharedApplication] delegate];
rootVC = ((MyViewController*)[[((UINavigationController*)[app.tabBarController.viewControllers objectAtIndex:0]) viewControllers] objectAtIndex:0]);
Run Code Online (Sandbox Code Playgroud)
我在测试中手动调用此代码来模拟UITableView上的单击:
[rootVC tableView:rootVC.tableView didSelectRowAtIndexPath:ip]; // push is called inside this
Run Code Online (Sandbox Code Playgroud)
所以我被卡住了我设置动画:是或动画:不.有没有人成功使用OCUnit来测试UINavigationController + UITableView的应用程序?如果是这样,请您分享一些示例代码或您的经验?
iphone objective-c ocunit uitableview uinavigationcontroller
代码:
UIViewController *viewController = [[UIViewController alloc] initWithNibName:@"NibName" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
navigationController.navigationBar.tintColor = [UIColor redColor];
self.popoverController = [[[UIPopoverController alloc]
initWithContentViewController:navigationController] autorelease];
popoverController.popoverContentSize = viewController.view.frame.size;
[popoverController presentPopoverFromRect:sender.frame inView:sender.superview
permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
[viewController release];
[navigationController release];
Run Code Online (Sandbox Code Playgroud)
色调颜色属性UINavigationBar不起作用,它仍然具有默认颜色.我能做错什么?
uinavigationbar uinavigationcontroller uipopovercontroller tintcolor ios
我正在做一个使用UINavigationController的应用程序,我正在切换到其他UIViewControllers,如下所示:
if(self.myViewController == nil){
MyViewController *aViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
self.myViewController = aViewController;
[aViewController release];
}
AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.myNavController pushViewController:myViewController animated:YES];
Run Code Online (Sandbox Code Playgroud)
我想这是在UINavigationController中创建一堆UIViewControllers,也许是一个索引数组?我想知道怎么回头而不必一个接一个地回来.
例如,我正在通过几个屏幕航行,并且我想在第一个导航索引处返回一个按钮.我还想知道如何修改索引,查看,擦除以及与此问题有关的任何内容.
对不起,如果我没有解释清楚.
我有一个UITabBarController,一个选项卡是UINavigationController.我有一个搜索栏,可以转到UINavigationController中的某个视图.问题是,如果第一个视图没有被UINavigationController推送,那么它会崩溃,因为我的搜索无法识别此调用中的visibleViewController:
UINavigationController *navController = [self.MainTab.viewControllers objectAtIndex:1];
FirstViewController *fVC = [navController visibleViewController];
Run Code Online (Sandbox Code Playgroud)
我不明白的是,在此代码之前,我这样做:
self.MainTab.selectedIndex = 1;
Run Code Online (Sandbox Code Playgroud)
这个代码本身选择了该选项卡中的viewController,然后根据我的知识加载视图.那么[navController visibleViewController]是否应该足以获取当前的viewController?谢谢.
iphone uitabbarcontroller uiviewcontroller uinavigationcontroller
我还没有在谷歌或堆栈溢出上找到类似的东西......
我想要做的是同时弹出模态视图和前一个视图.例如,查看日历应用.当您在Edit"屏幕上并选择Delete Event"时,您将被带回日历视图.在" Edit"画面,将其模态呈现弹出以及所述的" Event"画面(其中用户被刚刚观看日历事件).我遇到的问题是我知道如何弹出模态视图......但是从同一UIViewController个子类(Edit本例中的"屏幕")中,如何弹出一个非模态的视图?
我正在考虑像往常一样弹出模态视图,然后发布NSNotification到' Event'(例如)屏幕的UIViewController子类并告诉它也弹出该视图.
另一件事是,对于动画,它应该是dismissModalViewControllerAnimated动画(向下滑动)而不是popViewControllerAnimated动画(向左滑动).
谢谢.
另外,寻找比这更好的解决方案,这在我的情况下不起作用(至少没有popViewControllerAnimated)
当用户按下我的UINavigationController视图上的后退按钮时,我想显示带有2个选项的UIAlertView.一个选项(OK)允许用户返回(到前一个屏幕),另一个选项(Cancel)将保留在当前控制器上.
我在viewWillDisappear中实现了以下代码(我在这里找到了):
-(void) viewWillDisappear:(BOOL)animated{
if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
// back button was pressed. We know this is true because self is no longer
// in the navigation stack.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"All Data will be lost"
message:@"You must be connected to the internet to use this app."
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
alert.tag = 1;
[alert show];
[alert release];
}
[super viewWillDisappear:animated];
}
Run Code Online (Sandbox Code Playgroud)
问题是,在我按下Back后,视图立即跳转到previos屏幕并在此屏幕上显示UIAlertView.
在UIAlertView回调方法中,我使用了以下编码,但没有任何反应(我认为这是因为我之前已经在上一个视图中):
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex == 1)
NSLog(@"back");
//Go Back ...
}
Run Code Online (Sandbox Code Playgroud)
BR,mybecks
我试图用代码推入一个新的视图控制器:
[self.navigationController pushViewController:webViewController animated:YES];
Run Code Online (Sandbox Code Playgroud)
但它不起作用.在表视图中选择单元格时会发生此代码.我有一个表视图,我认为这是防止这种情况发生的.我试过以模态方式呈现它,但摆脱了导航栏,我不能回去.有一个非常类似于此但答案对我不起作用!
UPDATE
- (void)loadView {
// Create an instance of UIWebView as large as the screen
CGRect screenFrame = [[UIScreen mainScreen] applicationFrame];
UIWebView *wv = [[UIWebView alloc] initWithFrame:screenFrame];
// Tell web view to scale web content to fit within bounds of webview
[wv setScalesPageToFit:YES];
[self setView:wv];
[wv release];
}
Run Code Online (Sandbox Code Playgroud)
将Web视图作为WebViewController的视图
如上所示没有笔尖
使用NSLog查询didSelect单元格方法以查找
一切都被初始化和分配,非零
更新:
我做了选择细胞方法:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Push the web view controller onto the navigaton stack - this implicity
// creates the …Run Code Online (Sandbox Code Playgroud) xcode objective-c uitabbarcontroller uinavigationcontroller pushviewcontroller
今天最奇怪的错误:
2011-12-17 08:52:50.565 ShowLink[625:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITextInputTraits length]: unrecognized selector sent to instance 0x2aa240'
*** First throw call stack:
(0x37eb68bf 0x3199c1e5 0x37eb9acb 0x37eb8945 0x37e13680 0x352e4d9b 0x352aa0fd 0x352ac24d 0x352aa8e5 0x352aa259 0x352aa1b3 0x352aa12f 0x3539a623 0x352ad503 0x352acef5 0x352a76ff 0x352a7349 0x3d29 0x37e10435 0x352899eb 0x352899a7 0x35289985 0x352896f5 0x3528a02d 0x3528850f 0x35287f01 0x3526e4ed 0x3526dd2d 0x3798bdf3 0x37e8a553 0x37e8a4f5 0x37e89343 0x37e0c4dd 0x37e0c3a5 0x3798afcd 0x3529c743 0x211d 0x20dc)
terminate called throwing an exception(gdb)
Run Code Online (Sandbox Code Playgroud)
标准导航控制器应用程序,我发誓,没有打电话或与UITextInputTraits有任何关系.当我在堆栈上推送新控制器时会发生这种情况.
为了测试,我将控制器击败到它的裸骨,但仍然在推送后得到错误(被推送的控制器viewDidLoad和viewWillAppear被调用,这似乎发生在较低级别)
ios ×6
iphone ×6
objective-c ×3
xcode ×2
back-button ×1
exception ×1
ocunit ×1
sdk ×1
tintcolor ×1
uitableview ×1