我有一个UITableView,显示在UINavigationController中.我正在尝试更改表格下方视图的颜色,这样当您向下拉桌子时,您会看到除白色之外的其他内容.
我试过这两个:
self.tableView.backgroundView.backgroundColor = [UIColor blackColor];
self.navigationController.view.backgroundColor = [UIColor blackColor];
Run Code Online (Sandbox Code Playgroud)
分开和一起.仍然看到白色.
我错过了什么?
我想知道如何初始化UINavigationController以显示堆栈中的第三个视图控制器?有点像邮件应用程序.即使你杀了应用程序,当你启动它时,你会看到包含所有邮件的视图控制器,并有"后退"按钮,允许你进入邮箱列表.
谢谢你的回答.
Apple的文档说:
Note: Because the amount of space available for the custom view can vary
(depending on the size of the other navigation views), your custom view’s
autoresizingMask property should be set to have a flexible width and height.
Before displaying your view, the navigation controller automatically
positions and sizes it to fit the available space.
Run Code Online (Sandbox Code Playgroud)
这很好,除了...我需要知道UINavController将在视图添加到帧之前使用的大小,因为我将显示的内容根据大小而不同.
这是在UIViewController的"loadView"方法中,它被添加到UINavigationController中.
在研究和试图弄清楚如何解决以下问题时,我已经在键盘上打了3天以上.
我有一个看起来像这样的故事板:
初始应用程序启动箭头 - >到导航控制器 - >到主视图控制器.
我的appDelegate正在创建managedObjectContext,它用数据填充一些实体(仅用于测试目的,一旦我准备好与外部源集成,它将被删除).这工作很好.现在我的问题是我不知道我如何将MOC从appDelegate传递到我的第一个ViewController,因为导航控制器挡住了.我在appDidFinish方法中的当前代码如下所示:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Pass the managed object context to the root view controller
MainMenuViewController *rootView = (MainMenuViewController *)self.window.rootViewController;
rootView.managedObjectContext = self.managedObjectContext;
//My actual Core data setup and adding data to it, it works I've tested it.
return YES;
}
Run Code Online (Sandbox Code Playgroud)
现在,当我将故事板中的应用程序启动箭头指向我的mainMenuViewController时,我的代码可以正常工作,但是我的所有视图中都丢失了导航栏.我也知道如何将MOC从我的mainMenu传递到另一个视图,- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender但我似乎无法弄清楚如何从appDelegate到MainViewController进行初始传递,因为两个导航控制器位于两者之间.
我已经在这个网站(和其他人)上搜索了很多线程,我只找到了"选项卡式应用程序"的解决方案,其他人希望我序列化该对象,但出于我的目的,我不能这样做.(只有少数视图会收到MOC,而其他视图会传递一个视图创建和更改的数据,以便在独特视图中针对特定目的进行定制)
非常感谢iOS和Objective-C对此nub的任何帮助.先感谢您.
编辑:我得到的错误是"由于未捕获的异常终止应用程序... [UINavigationController setManagedObjectContext]无法识别的选择器发送到实例...
我在appDelegate中创建了一个导航控制器(以编程方式).我想在导航栏中添加一个自定义按钮,以便显示所有视图.
我可以让按钮显示我是否在每个控制器的ViewDidLoad方法中添加它,但是有一种方法我只能添加按钮一次(即在我创建导航控制器的appDelegate中)?
我有一个故事板,有三个视图A,B和C(以及更多).从视图B,用户可以通过点击自动创建的左按钮栏项返回查看A. 我已经通过设置A导航项的Back Button属性将其上的标签更改为"取消".
C应该有相同的取消按钮,但返回查看B是没有意义的; 相反,它应该跳回到A.我知道如何以编程方式执行此操作但是我在哪里放置代码,以便在点击C的取消按钮时触发它?
我的AppDelegate中有一个名为handleLocalNotification的方法,当我的应用程序收到通知时会触发该方法.我需要它切换到包含UITableview的UITabBarController中的tab 0.然后我需要它来推送tableview的正确行以显示通知发送的记录.所有控制器都在故事板中创建,因此我在AppDelegate中没有引用它们.
我已经添加到我的AppDelegate.h:
@class MyListViewController;
@interface iS2MAppDelegate : UIResponder <UIApplicationDelegate> {
MyListViewController *_listControl;
}
Run Code Online (Sandbox Code Playgroud)
为了测试我只是把它放在didFinishLaunchingWithOptions方法中:
UITabBarController *tabb = (UITabBarController *)self.window.rootViewController;
tabb.selectedIndex = 0;
_listControl = [tabb.viewControllers objectAtIndex:0];
[_listControl.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:4 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];
Run Code Online (Sandbox Code Playgroud)
tabBarController位工作,因为我可以在不同的选项卡上加载它.最后两行导致它崩溃.我是否以正确的方式解决了这个问题?或者我需要使用不同的方法吗?崩溃的原因是:
UINavigationController tableView]:无法识别的选择器发送到实例
xcode objective-c uitabbarcontroller uinavigationcontroller ios
我想在我的应用程序中添加一个加载活动指示器,类似于邮件应用程序中的状态文本.我正在使用UINavigationController,所以我知道我需要在每个我希望它显示的视图上设置toolbarItems数组.我可以添加活动指示器,它确实显示,但当我尝试使用下面的代码添加文本字段时,文本不显示.有没有办法以编程方式创建一个具有状态文本和UIActivityIndicatorView的容器,如果将其添加到toolbarItems数组中,它将显示出来.
UIBarButtonItem *textFieldItem = [[[UIBarButtonItem alloc] initWithCustomView:textField] autorelease];
self.toolbarItems = [NSArray arrayWithObject:textFieldItem];
Run Code Online (Sandbox Code Playgroud)
更新:我根据来自pdriegen的代码创建了一个派生自UIView的类.
我还将此代码添加到我的控制器中的viewDidLoad
UIProgressViewWithLabel * pv = [[UIProgressViewWithLabel alloc] init];
UIBarButtonItem * pvItem = [[UIBarButtonItem alloc] initWithCustomView:pv];
[self setToolbarItems:[NSMutableArray arrayWithObject:pvItem]];
Run Code Online (Sandbox Code Playgroud)
目前工具栏中没有显示任何内容.我错过了什么?
xcode uinavigationcontroller uibarbuttonitem uiactivityindicatorview ios
我创建了一个带有一堆视图控制器的导航控制器.
我想在底部添加一个子视图,当用户在这一堆视图之间导航时,该子视图保持静态(不移动).
与某些应用程序一样,底部有一个"广告栏".
我怎样才能做到这一点?
我使用故事板设置我的应用程序并将主视图控制器嵌入到一个UINavigationControler.要更改导航栏中显示的标题,在viewDidLoad我的主视图控制器的方法中,我有self.navigationItem.title = @"My Title";但标题永远不会被设置.
我的猜测是我需要在我的故事板中设置一个参考插座,但我不确定需要与什么相关联.有任何想法吗?
uinavigationbar uinavigationcontroller uinavigationitem ios uistoryboard
ios ×8
iphone ×3
xcode ×3
delegates ×1
ipad ×1
moc ×1
objective-c ×1
storyboard ×1
three20 ×1
uistoryboard ×1
uitableview ×1
uiview ×1
view ×1