I have an app with a segmentedControl in the titleBar, which is used to switch between 3 navigation controllers. I am using the new appearence proxy methods to style this segmentedControl (code below). However, there seems to be some sort of bug that I cannot figure out. It appears when I dive into one of the navigation controllers and then navigate back to the root (which then shows the segmentedControl in the top bar again). When that happens the divider graphics get messed up as you can see in the screenshot (the first one shows what it's supposed to look like).
Has anyone encountered anything similar and knows how to fix it?
My code to set the appearence is:
UIImage *segmentSelected = [[UIImage imageNamed:#"sel"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 6, 0, 6)];
UIImage *segmentUnselected = [[UIImage imageNamed:#"uns"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 3, 0, 3)];
UIImage *segmentSelectedUnselected = [[UIImage imageNamed:#"sel-uns"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 6, 0, 6)];
UIImage *segUnselectedSelected = [[UIImage imageNamed:#"uns-sel"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 6, 0, 6)];
UIImage *segmentUnselectedUnselected = [[UIImage imageNamed:#"uns-uns"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 6, 0, 6)];
[[UISegmentedControl appearanceWhenContainedIn:[UINavigationBar class], nil]
setBackgroundImage:segmentUnselected forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UISegmentedControl appearanceWhenContainedIn:[UINavigationBar class], nil]
setBackgroundImage:segmentSelected forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
[[UISegmentedControl appearanceWhenContainedIn:[UINavigationBar class], nil]
setDividerImage:segmentUnselectedUnselected forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UISegmentedControl appearanceWhenContainedIn:[UINavigationBar class], nil]
setDividerImage:segmentSelectedUnselected forLeftSegmentState:UIControlStateSelected rightSegmentState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UISegmentedControl appearanceWhenContainedIn:[UINavigationBar class], nil]
setDividerImage:segUnselectedSelected forLeftSegmentState:UIControlStateNormal rightSegmentState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
[[UISegmentedControl appearanceWhenContainedIn:[UINavigationBar class], nil]
setContentPositionAdjustment:UIOffsetMake(8, 0) forSegmentType:UISegmentedControlSegmentLeft barMetrics:UIBarMetricsDefault];
[[UISegmentedControl appearanceWhenContainedIn:[UINavigationBar class], nil]
setContentPositionAdjustment:UIOffsetMake(-8, 0) forSegmentType:UISegmentedControlSegmentRight barMetrics:UIBarMetricsDefault];
what it is supposed to look like:
what it looks like:
I've used a backgroundImage for UINavigatorBar via appearance and noticed that using that approach together with a UISplitViewController/UIPopoverController the whole navigation bar is moved into the content area. So you just see the darkblue border and the customized Navigation bar is positioned right below the border looking very strange.
No help for you but it might be a real bug?!
I've had the same issue. Eventually I ended up using a 1px wide divider image -> then the issue disappeared.
Please make sure you are using this in app delegate didfinishLaunching applied for all the view controller.I have the same problem image overlapped . use it in one place problem resolved .Try with [uiview class] instead of [uinavigationBar class]
Related
Does anybody know, how I can make the UINavigationBar solid black in IOS7? Default it is white, and I need it black.
If you're targeting only iOS 7 you can use:
[[UINavigationBar appearance] setBarTintColor:(UIColor *)];
Here is one way that creates a black UIImage programmatically and sets it for the UINavigationBar's appearance:
UIView *background = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 568, 44)];
background.backgroundColor = [UIColor blackColor];
UIGraphicsBeginImageContext(background.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[background.layer renderInContext:context];
UIImage *backgroundImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[UINavigationBar appearance] setBackgroundImage:backgroundImage
forBarMetrics:UIBarMetricsDefault];
found it by myself. Go into storyboard-designer, select the ViewController, go to attribute inspector and change Top Bar from inferred to 'Opaque black navigation bar'
I'm trying to align an imageView at the bottom of my UIViewController, but on iPhone 5 simulator it isn't aligned on the bottom.
I've tried to put an imageView at the bottom of the storyboard and it is aligned correctly so I guess I miss something in my code.
Any advice?
Thanks,
e.
imageView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 416, 320, 64)];
[imageView setContentMode:UIViewContentModeScaleToFill];
imageView.autoresizingMask=UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin;
[self.view addSubview:imageView];
got it, used
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:#"V:[xmlView]|"
options:0
metrics:0 views:NSDictionaryOfVariableBindings(xmlView)]];
Set the Frame Size like this:
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x, self.view.frame.size.height-64, 320, 64)];
[imageView setContentMode:UIViewContentModeScaleToFill];
[self.view addSubview:imageView];
Hope this will help.
I have a UITextView with a lot of text in it. When the subview containing the UITextView is shown the UITextView only appears after the UITextView has been touched and scrolled.
Is there a limit of how much text can be in a UITextView?
Or is this a bug?
attached is a clip explaining this occurrence.
https://dl.dropbox.com/u/8256776/UITextView%20Bug.MOV
Ok, I have looked into it and it seems to be quite a common issue. It seems that the text view doesn't feel that it has to draw the text, but calling setNeedsDisplay doesn't help. I don't know if there is a "real" solution, but you can force it to draw the text by scrolling programmatically:
disclaimerView.contentOffset = CGPointMake(0, 1);
disclaimerView.contentOffset = CGPointMake(0, 0);
An unrelated thing in your code: In your switchView method you have two animations, one for the menu view and one for the view you are sliding into place. This is unnecessary as you can put both setFrame calls in the same animation:
MenuView = (UIView *)[self.view viewWithTag:100];
appView = (UIView *)[self.view viewWithTag:ViewInt];
[MenuView setFrame:CGRectMake(0, 0, 320, 480)];
[appView setFrame:CGRectMake(321, 0, 320, 480)];
[UIView beginAnimations:#"move buttons" context:nil];
[UIView setAnimationDuration:.5];
[MenuView setFrame:CGRectMake(-320, 0, 320, 480)];
[appView setFrame:CGRectMake(0, 0, 320, 480)];
disclaimerView.contentOffset = CGPointMake(0, 1);
disclaimerView.contentOffset = CGPointMake(0, 0);
[UIView commitAnimations];
And one more thing (and then I will back off :) )
You seem to be quite fond of using tags to retrieve elements. While it does work, it is not very understandable. You don't have that many elements so I would just add each of them as IBOutlet with a meaningful name (like you did with your disclaimerView). Also, have seperate switchView methods for the different views you are moving into place. That way you can easily perform additional stuff you might need for just that view, like the force scroll on disclaimerView.
I'm able to set the MKPinAnnotationView with title, subtitle, an image on the left (leftCalloutAccessoryView) and a button on the right (rightCalloutAccessoryView).
With this code i set the image on the left:
UIImageView *myImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"Icon.png"]];
myImageView.frame = CGRectMake(0, 0, 10, 10);
customPinView.leftCalloutAccessoryView = myImageView;
[myImageView release], myImageView = nil;
The result is something like this:
Image 1
but I would like to get something like this:
Image 2
where the image is aligned with the subtitle.
How can get it?
Thx.
That's going to require using a custom annotationView. There's plenty of documentation about this in the developer resources. There's no way to do that image alignment using the default annotation style.
I created programmatically a multi view iphone application.
when adding objects to a view, like a button for example. in position x = 0, y = 0
this results to x = 0, y = 20 in the iphone simulator.
this is the used code :
UIButton *btnGoToStartView = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btnGoToStartView.frame = CGRectMake(0, 0, 240, 30);
[btnGoToStartView setTitle:#"Btn Name" forState:UIControlStateNormal];
[btnGoToStartView addTarget:self action:#selector(myBtnAction) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btnGoToStartView];
In the other hand, when I'm placing a button using Interface Builder in position x = 0, y = 0 the result is good.
Till now I didn't found the real reason for this vertical shifting.
Thanks in advance for your hints.
Regards.
It's Ok, I found the solution.
It's a problem of the UIView not the control.
in Interface builder, I opened the MainWindow.xib then I modified the attribute Layout in the inspector window.
I checked [wants full screen].
That's all.