I am setting the view as a subview in UIWindow. It's working fine as such. I am able to load the view and do my work; however, if I actually go and change the background color, in a small area at the bottom the color doesn't change.
This is the code that I am using to add this view as a subview to Window
UIWindow* keyWindow= [[UIApplication sharedApplication] keyWindow];
[keyWindow addSubview: self.view];
This is the code to change the color:
self.view.backgroundcolor =[UIColor bluecolor];
This behaviour happens only in iOS6. In iOS7, the background color changes completely.
#Fogmeister is correct you should add a rootViewController to it, but just replying your question, your view has not the same size of the window, so this small area at the botton is the uiwindow you are seeing behind your view. You can just set the frame of your view with the same size of the window self.view.frame = keyWindow.bounds;
Related
I have a ViewController with a Navigation Controller before it, that has a TableView and other elements inside. The tableView has also a Search Bar, and in the scene, besides the main ViewController I have a Search Display Controller.
The functionality is working, but I have the following UI issues:
Although my main view has black background colour(and most of the elements have black background colour), when I drag the tableView downwards there appears some white space.
I also have the following initial setup for UI
-(void) viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
self.view.backgroundColor = [UIColor blackColor];
self.tableView.backgroundColor = [UIColor blackColor];
self.searchDisplayController.searchResultsTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
self.searchDisplayController.searchResultsTableView.separatorColor = [UIColor blackColor];
self.searchDisplayController.searchResultsTableView.separatorInset = UIEdgeInsetsMake(0, 12, 0, 12);
[self.searchDisplayController.searchResultsTableView setBackgroundColor:[UIColor blackColor]];
[self.searchDisplayController.searchContentsController.view setBackgroundColor:[UIColor blackColor]];
self.searchDisplayController.searchBar.barStyle = UIBarStyleBlack;
self.searchDisplayController.displaysSearchBarInNavigationBar = NO;
}
When I search for a result, and drag the table upwards after the Search Bar, there is a small place where the table view is visible.
Any ideas how can I fix this :(?
Edit update:
Both were solved removing the Search Bar from the TableView. After this another issue came that the animation of Search Display Controller wasn't updating the Search Bar. this was solved with the following post:
UISearchBar animation issue
You have to set UIView background color to black (not just UITableView color).
You have to position your table view below UISearchBar, you can do this either programmatically or via IB. I recommend second option. Pretty easy.
I have created a screen tutorial for my app.
I've done this by creating a PageViewController to manage 4 viewControllers.
In the PageViewController I have implemented the following code
self.modalPresentationStyle = UIModalPresentationFormSheet;
I have also set the alpha on the pageViewController view to .45
This makes the PageViewController transparent which is exactly what I want.
However, it is also making everything inside the 4 viewControllers that are being managed by the PageViewController transparent i.e. buttons, labels, etc.
How can I stop all of those object from being transparent?
Views always work like this. If you wanted to make a view semi-transparent, it would usually be pretty vexing if that didn't also affect all of its subviews. The times when you want your alpha setting to also affect the subviews likely far outnumber the times when you don't.
What you can do instead of making the view transparent is to make its background color transparent. That is, instead of:
self.view.backgroundColor = [UIColor blueColor];
self.view.alpha = 0.45;
you can do:
self.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:1 alpha:.45];
That way, your subviews are not affected, because while the alpha of your main view's background color is 0.45, the alpha of the view itself is still 1.0.
To change the background color of a view, use the following on the view:
[viewController.view setBackgroundColor:[UIColor COLOR]];
where COLOR is the color you would like (i.e. whiteColor)
In my main view, I add a normal UIToolbar to the bottom of the frame, in landscape it doesn't get smaller? Is this because i dont supply landscape images or am i missing something else? All of the other toolbars in the UINavigationController's all change size in landscape.
Heres how i add this one to the screen.
toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-64, SCREEN_WIDTH, 44)];
toolbar.translatesAutoresizingMaskIntoConstraints = YES;
[self.view addSubview:toolbar];
[self setupToolbarItems];
setupToolbarItems just creates some of the images for the bar buttons and sets them.
A UIToolbar that you add yourself will not magically change height. If you want it to do so, you must change the height yourself in response to a change in app orientation.
The behavior that you have observed, where a bar changes height, is a feature of UINavigationController; it changes the height of its navigation bar and its toolbar in response to orientation change (as explained in my book: http://www.apeth.com/iOSBook/ch25.html#SBbarMetrics). But this UIToolbar does not belong to a UINavigationController so nothing happens to its height automatically. It's up to you.
This is because you are creating the toolBar's frame but not setting it again when the view is rotated. You need to check when the screen is rotated using [[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(resize) name:UIDeviceOrientationDidChangeNotification object:nil];
and then in your -(void)resize; method, you need to resize the toolbar to the new window's size.
CGRect rect = CGRectMake(0, 0, 1050, 900);
[wineAdminPopup presentPopoverFromRect:rect inView:master.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
Hi I put the above code to make a popup in a tableview. However it doesn't popup in the whole screen. If I want to center it in the iPad screen with no arrow or arrow in the center. How can i do it. Thanks in advance.
The rect parameter in presentPopoverFromRect:... specifies the rectangle at which to anchor the popover, not the size of the presented popover. That would be specified by setting contentSizeForViewInPopover on the popover's content view controller.
If you don't want the arrows and don't need the specific behavior of popovers, then you could
present your view controller modally:
controller.modalPresentationStyle = UIModalPresentationFullScreen; // or UIModalPresentationFormSheet
[self.navigationController presentModalViewController:controller animated:YES];
presentModalViewController is deprecated in iOS 6 and above. Use presentViewController:yourViewController animated:YES completion:nil (parameters animated and completion can be set depending on your requirements). Also if you want to resize yourViewController you need to change self.view.frame and next time your view controller will be of that size.
I've been trying to build a specific look for my menubar app.
I've been using a NSWindow with a NSBorderlessWindowMask style mask and setting [window setOpaque:NO] and [window setBackgroundColor:[NSColor clearColor]]. That gives me a blank canvas which works great for the title bar.
Now I'm having problems with the view-based NSTableView I'm using for the listing. How can I clip the NSTableCellViews to the window's rounded corners?
I started out just having a custom view wrapping the NSTableView, drawing the background with rounded corners. Using [view addClip:path] doesn't clip child views though.
I've also tried using a [view setWantsLayer:YES] with a mask. That worked great, but the table view cells would sporadically glitch out. It seems that having a NSScrollView be a child of a layer is a known problem:
My current view structure looks something like:
NSWindow
- MyTitleBarView
- MyBackgroundView
- NSScrollView
- NSTableView
I found one way to do it:
The trick is to keep the window style as the default and not set NSBorderlessWindowMask. Then you can add your custom title bar view to the window's theme frame like so:
NSView *themeFrame = [[window contentView] superview];
NSView *firstSubview = [[themeFrame subviews] objectAtIndex:0];
[titleBarView setAutoresizingMask:(NSViewMinYMargin | NSViewWidthSizable)];
[themeFrame addSubview:titleBarView positioned:NSWindowBelow relativeTo:firstSubview];
This basically just puts your custom title bar view on top of the standard title bar. You'll probably have to do some rejiggering to the view frames and window buttons. See INAppStoreWindow for some code examples of this.
The INAppStoreWindow project says that this method doesn't use any private APIs, and thus is able to be used on the App Store.
If you require the window to be transparent, you can just set the following on the window:
[window setOpaque:NO];
[window setBackgroundColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.5]];