UIView appearing before navigation transition is over - uiview

I'm writing an iPhone app with a table inside a navigation controller. When the user clicks one of the cells in the main screen a UIView on top of the incoming view controller is created (it's like a toolbar).
self.toolbar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 45)];
toolbar.backgroundColor = [UIColor colorWithRed:0.8823 green:0.8823 blue:0.8823 alpha:1.0];
[self.navigationController.view addSubview:toolbar];
The problem is that the view appears before the transition to the new view controller is complete and the effect is pretty weird. I suppose this is due to the fact I add the view to the navigationController,but I need to do this otherwise the bar would scroll together with the table and instead I want it to be fixed.
Any suggestion?

I've found a possible solution: add the toolbar as TableHeaderView and follow iOS: Add UIView to UITableView
Any other better solution is more than welcome

Related

Sidebar menu with indicate navigationbar on iOS

I want to create sidebar menu with indicate UINavigationBar like below mention image.
By using ECSlidingviewController library i have done side menu. But thing is i need to display Navigation Indicator when user slide on menu.
How can i create? Any one having idea?
There is nothing special to do here.
Simply create your view and add it as a subview of the navigationBar in your controller (not the menu controller).
Here is a simple demonstration:
CGFloat desiredWidth = x;<----replace x.
UIView *testView = [[UIView alloc]initWithFrame:CGRectMake(-desiredWidth,0,desiredWidth,44)];
[testView setBackgroundColor:[UIColor blackColor]];
[self.navigationController.navigationBar addSubview:testView];

ios7 status bar overlaps toolbar when using container view

I´v read the posts regarding this issue but found nothing to work, I think it must be since I am using a toolbar and have the View Controller embedded in a container view. The status bar always overlaps. No matter if I try to replace the toolbar or set different settings in IB. It also seems that since it´s inside a container view, setting the inferred option does not work. I even tried putting two toolbars on top, but only this one shows.
The status bar in iOS 7 is transparent, so if you want to have a look similar to that of iOS6, create a view of 20 pixels and add it inside your "container" view...
UIView *statusBarView = [[UIView alloc] initWithFrame: CGRectMake(0, 0, 320, 20)];
statusBarView.backgroundColor = [UIColor blackColor];
[containerViewController.view addSubview:statusBarView];
Then set the frame of your "contained" ViewController accordingly
containedViewController.frame = CGRectMake(0, 20, 320, itsCurrentHeight - 20);
This way the status bar should not overlap with your content anymore

ios - UIView to cover full screen, to cover the tabs from a UITabBarController

I have a UITabBarController and I want to add a UIView as a subview but I want that view to cover the whole screen including the tabs on the bottom. All attempts I have done result in the view cover everything except the tabs on the bottom.
Not sure what you have tried but, if you are trying to add the view from a UIViewController that is inside the UITabBarController then you should use:
UIView *coverView = [[UIView alloc] initWithFrame:CGRectMake(0,
0,
self.tabBarController.view.frame.size.width,
self.tabBarController.view.frame.size.height)];
[self.tabBarController.view addSubview:coverView];
//and maybe [self.tabBarController.view bringSubviewToFront:coverView];

iOS UITableView: UIView/custom cell at the bottom like in twitter iPad app

I am creating an iPad app using the master-detail template available in Xcode 4.3. My master tableview is acting as a navigation menu for the detail view and the menu items will be fixed. So I basically don't exactly need the scrolling view, thus I have turned it off.
self.tableView.scrollEnabled = NO;
Now I have a requirement to display a footer like cell aligned at the bottom of master menu just like in Twitter iPad app. The cell should appear at the bottom in landscape as well as portrait modes. Can somebody give me some hints regarding how to implement this?
I read on some blogs about using a UIView and setting it to UITableView.tableFooterView, something like this...
// I'll have to do calculations of frame height/x/y for both orientations
// to make the view appear at bottom - IS THERE A SIMPLER WAY???
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 944, self.tableView.frame.size.width, 60)];
UILabel *logo = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 60)];
logo.text = #"This is the Footer.";
[footerView addSubview:logo];
self.tableView.tableFooterView = footerView;
After looking at the app, I don't think the "footer" is part of the table. It looks more like a small view under the table. So the table is set up so it will stretch vertically but it's height is locked above the bottom view. Maybe it would be better to use a UIViewController and a UIView for you Master View instead of a UITableViewController. Then put your UITableView in the UIView and put your footer below it. Then configure the UIViewController to work with the UITableView as it did before.
Hope this helps.

bad_Access exception when typing in UITextView

I don't know what is wrong with this code; when i start typing in the UITextView, the program terminates with exc_Bad_Access exception.
UIView *toolbar = [[UIView alloc] initWithFrame:CGRectMake(0, 430, 320, 44)];
toolbar.backgroundColor = [UIColor lightGrayColor];
UITextView *sendTextView = [[UITextView alloc] initWithFrame:CGRectMake(10, 9, 240, 26)];
sendTextView.backgroundColor = [UIColor whiteColor];
sendTextView.inputAccessoryView = toolbar;
sendTextView.layer.cornerRadius = 12.0;
[toolbar addSubview:sendTextView];
[self.view addSubview:toolbar];
The above code is inside the viewDidLoad method of a UIViewController which has a UIScrollView as its view.
Putting an editable text view in a toolbar seems strange. (What do you do when the user wants to edit it? Move it up above the keybaord? I wouldn't expect a toolbar to move OR to contain an editable field.) Nevertheless, I'd be surprised if doing that caused EXC_BAD_ACCESS.
Your problem is more likely in code that actually runs when you're typing, such as one of the text view delegate methods. If you can't find anything there, please post the stack trace at the time of the crash and code for the method that was actually running at the time.
Update: After you pointed it out in your comment, I see that you're setting the toolbar as the input accessory view for sendTextView and adding it to the view controller's view. I'd guess that what's happening here is that when you start editing the text view, the text view adds the toolbar to the keyboard's view without first removing it from the view controller's view. A given view can only be part of one view hierarchy at a time; adding it to your view and using it as the input accessory view won't work. If you look at Apple's sample code for using an accessory view you'll find that the view used as the accessory isn't part of the normal view hierarchy.

Resources