I am calling a UITabBarController and displaying it as a popover, however when the popover is displayed, at each corner there is a little white edge (the views within have a coloured background).
In any other UIPopoverController I would set the class of the view to a .m file and then use the following code in the viewDidLoad method:
self.popoverPresentationController.backgroundColor = [UIColor blackColor];
However I am unable to set a custom class to a UITabViewController and so am unable to do this.
I have attempted to set the above code in the individual tabs once they load however this has no impact as they are sub-views of the UITabViewController.
Has anyone got a solution for this? I have searched all over for an answer and it is eluding me.
Related
When i drag and drop a UIView on storyboard and when i do the same on the Storyboard Upper BAR. (where we generally find 3 options)
A. Name of the class.
B. First Responder.
C. Exit.
So it seems it is used just to provide a good symmetry in storyboard and to keep the things nice and clean.
I have been looking for it for many days but no where i find anything about this particularly.
I have done it like below:
from assistant editor i create an object named ScoreCardView. (there is one more view, due to scrollview, and then tableView).
_ScoreCardView.frame = CGRectMake(0, 10, ScreenWidth, ScreenHeight-50);
_ScoreCardView.backgroundColor = [UIColor greenColor];
_ScoreCardView.transform = CGAffineTransformMakeRotation(M_PI/2);
[self.view addSubview:_ScoreCardView];
[self.view bringSubviewToFront:_ScoreCardView];
I want it to rotate landscape(even in portrait mode), but tab bar would remain as it is.
Its working fine if a use UIView on the storyboard itself, but not with (UIView extension view ?)
Kindly Help.
The only difference is when you add view on your controller you need not to add view to the controller's view. On the other hand if you add that view on the top bar of the controller you have to add that view as subview using code:
self.view.addSubview(viewToAdd)
Thanks.
I am working on a iOS (Swift) project. I am trying to embed a UINavigationController inside a container view. As seen:
It goes: UITabBarController -> UIViewController: container view -> UINavigationController -> UIViewController
I have hidden the Navigation Bar and Toolbar for the UINavigationController
Everytime I run it, I am getting this result (the red is the container views background)
Why is this happening? and how can I get rid of the red bar and make the tableview fill the whole container view?
BTW: If I embed the table view to the container view directly, I don't have this problem. It only seems to happen when using a navigation controller.
Try this answer https://stackoverflow.com/a/27149012/1570786
The above method works fine in iOS8, in iOS7 it doesn't work as expected.
This looks similar to an issue I've had before concerning the setAutomaticallyAdjustsScrollViewInsets property on UIViewController. Try playing with that on your FilterViewController.
Another thing you could try is setting constraints around your table view inside your FilterViewController to make sure it is attached to the edges of the view. (This can be ignored if FilterViewController is a subclass of UITableViewController).
I have a UITableView which is presented modally over a view. One of the cells in the table view is deliberately transparent so that the view underneath is visable. The issue is that is IOS 7.1 the cell starts off transparent and then immediately becomes opaque. Under iOS 8 the transparent cell technique works perfectly.
Qn. Has anyone seen this and come up with a valid work-around?
Things I've tried
Adjusting cell.backgroundColor
Adjusting cell.backgroundView
Adjusting tableView.backgroundColor
Adjusting tableView.backgroundView
Setting tableView.opaque = YES;
Making the adjustments in tableView:cellForRowAtIndexPath:
Making the adjustments in tableView:willDisplayCell:forRowAtIndexPath:
Using full transparencies
Using partial transparencies
Using transparent images
[[UITableViewCell appearance] setBackgroundColor:[UIColor clearColor]];
Essentially as soon as any transparency is introduced into the background it changes (after a slight pause to become opaque).
To re-iterate under iOS7 the transparency is there very briefly (less than a 1/2 sec) then it turns opaque.
Here is a vimeo of the effect: Link
Rather than focusing on the tableview and it's cells, look at the presenting (bottom) view controller. I believe (although I can't find it officially documented at the moment) that when you do a standard modal presentation of one view controller over another, the presenting view controller's view is removed from the view hierarchy after presentation. Working with a trivial test app, the presenting view controller's -viewWillDisappear: is called and logging the key window's -recursiveDescription show the presenting view controller's view has been removed.
However, if you use a custom transition, the presenting view controller's view is kept in place (presumably to allow for exactly this kind of transparency effect).
EDIT: I've put together a quick example app (here: https://github.com/sjc/ViewControllerTransitionExample) to 1) illustrate the difference in behaviour between standard and custom modal presentation, and 2) to show how a basic UINavigationController subclass can be built to solve this issue (the technique is normally just applied to straight UIViewController subclasses).
However... While this can be used to solve the issue in this case, it doesn't answer the 'what's going on here?' question, since the example doesn't reproduce exactly what you are seeing: the presenting view controller disappears on both iOS 7 and 8, and not just on 7, as described in the original question. Oh well.
try to change to table cell from the Appearance system in your AppDelegate
[[UITableViewCell appearance] setBackgroundColor:[UIColor clearColor]];
This won't work on iOS 7 because modal views are always opaque. On iOS 8 they can be transparent.
You will have to find another solution on iOS 7.
That is seems to work for 1/2 of a second is because modal views aren't opaque during transition.
In complex screens (View Controllers) I used to separate the whole thing in smaller pieces (I call them widgets). These widgets consist basically of a MyWidget.h and a MyWidget.m file as well as a MyWidget.xib file, where the root element is a UIView and the MyWidget class is the File Owner of the UIView. In the init of this widget I do a loadNibNamed.
In my View Controller I then do a [[MyWidget alloc] init], which I add to View's Controller main view as a sub view. This, so far, works perfectly.
I'm now wondering, how to do the same with storyboard, because I cannot really start to drag in a UIView somewhere, I always have to start with an UIViewController, which I don't want to.
If there is no possible way doing this with a Storyboard, can I simply do it the old way, by using the Storyboard for my main screens and segues, and use a separate .xib file to define custom views?
Putting the widget/view in a separate .xib file works, and is appropriate especially if you might want to reference that same view from multiple View Controllers.
However, sometimes you do want to see the additional view/widget within the same storyboard, and it is possible. Here's how you do it:
Select your view controller in IB (click on the black bar below the view), then drag a UIView from the Object Library into the black bar:
When a view is in the black bar, it's instantiated like any other view in IB but just isn't added to your view hierarchy until you do so in code. Change the view's class to match your own subclass if necessary:
You can hook it up to your view controller like you would hook up any other view:
The added view shows up in your Document Outline and you can hook up actions and references there too:
Now, the problem that remains is that you can't actually see the view no matter how many times you try to click or double click, which would defeat the whole purpose of putting it in the same storyboard. Fortunately there are two workarounds that I know of.
The first workaround is to drag the view from the black bar back into your view controller's view, edit it, then drag it back into the black bar once you're done. This is troublesome but reliable.
The other workaround is more finicky, but I prefer it because it lets me see all my views at the same time:
Drag a UITableView from the Object Library into your newly added view.
Then drag a UITableViewCell into that UITableView.
Once you do that, your view pops out magically by the side, but you have a UITableView that you don't want. You can either resize that to 0x0, or you can delete it and your UIView will (usually) still stay visible.
Occasionally the secondary view will become hidden again in IB. You can repeat the above steps if you deleted the UITableView, or if the UITableView is still in the hierarchy you just need to click on the UITableViewCell and the view will appear again.
The second method works for UIViews but not so well for UIToolbars and is impossible for UIButtons, so the cleanest solution I've found when you need to include lots of different subviews is to attach a single secondary UIView to your view controller as a container that never gets shown, put all your secondary views in there, and use the UITableViewCell trick to make everything visible. I resize my dummy UITableView to 0x0 to make that invisible. Here's a screenshot of how it all looks like together:
If you're just looking to make your view controllers else-where(and not in your story-board), then there's a pretty simple way to accomplish this:
1) Create your CustomViewControllers(abcdController in the code I tried) with their individual xibs as usual.
2) Add a UIViewController(or whatever was the superclass of your CustomViewController) to the story-board.
3) Set the CustomClass to CustomViewController instead of UIViewController as shown here:
4) Finally, in your viewDidLoad, load the custom xib and you're done.
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSBundle mainBundle] loadNibNamed:#"abcdController" owner:self options:nil];
// Do any additional setup after loading the view from its nib.
}
I think you can do something like this to get instance of specific viewcontroller from Storyboard and use view on top of it.
ex:
MyViewController* myViewController = [[UIStoryboard storyboardWithName:#"Main" bundle:nil] instantiateViewControllerWithIdentifier:#"myViewController"];
UIView* view = myViewController.view; //Get the view from your StoryBoard.
Hope this helps
Thanks
Vijay
Does anyone know if it possible to have a transparent background for a UIPopOverController on the iPad?
I'd like to put a semi-transparent view inside the popover (hence the desire for the popover itself to have a transparent background).
I think it can't be done ... but I'd love to know if I am wrong!
I think that setting the transparency of the view in the popover won't work, but I've never tried it and it might.
Anyways, another cool way would be to take a UIImage rendering of the main UIView inside the popover controller.
Once you have this image, you can follow this process, assuming that you also know where the popover is positioned (its CGRect) relative to the view controller that opened it.
Hide popover.
Show rendered UIImage in a transparent UIImageView at the same position. (You can add a little border yourself so that it looks like the popover too.)
Reshow the popover.
The effect would be that the UIPopoverController "faded".
I know its a hard way to do it if the first solution also works, but this might be cool project to take on.
Why not add a View whose alpha is setted to 0.5 before showing popover view
then use
presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated;
method of popover passing the created view's reference.
It is possible to have UIPopOverController to have semi-transparent background. Check the following example.
[[[myPopOverController contentViewController] view] setAlpha:0.25f];
Usually popover control wil be transparent,we cant change the popover control to semi-transparent view