Is there any other style presenting an UIAlertView? - iphone

I saw one app in which the notification/alert view was coming from the top of the iphone screen with gradient black color.
May I have details about alert/notification styles if any?

you may use this link ... maybe it will help you. one other way is to use UIActionsheet.
http://joris.kluivers.nl/blog/2009/04/23/subclass-uialertview-to-create-a-custom-alert/

There's the UIActionSheet—but it is raises from the bottom.

Unfortunately not. And customize the original UIAlertView is a trick, that acts on subviews hierarchies. you can sub class it and change it's background color overriding the drawRect: method and removing the original background with those lines of code
- (void)didAddSubview:(UIView *)subview {
if ([subview isMemberOfClass:[UIImageView class]]) {
[subview removeFromSuperview];
}
}
But it is a trick and it could be lost in future release of iOS

Related

Using background view for UITableViewCell in iOS 7 covers default delete button

I am using background view for UITableviewCell which is an imageview, I am using the image view to achieve two side corners for first and last cell. It is working fine But the problem is when I use this background view, the default cell delete button which comes when we press the tableviewcell default edit button is being covered by the background view.If I give clear color for the background view it is working fine but I want background view to be set.
Is there any idea why the delete button is being covered or hidden by cell background view?
It happens in iOS 7
Please help! thanks in advance.
how about instead of using the background view. just use your image as the background patternn color try using this
cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:YOUR_IMAGE]];
Had the exact same issue. Solved it by sending the backgroundView to back when transition starts & also again on the next runloop cycle (using dispatch_async).
Here's the code you should add to your cell class .m file (i.e. MyCustomTableCellView.m)
// Fix for iOS7, when backgroundView comes above "delete" button
- (void)willTransitionToState:(UITableViewCellStateMask)state {
[super willTransitionToState:state];
[self sendSubviewToBack:self.backgroundView];
dispatch_async(dispatch_get_main_queue(), ^{
[self sendSubviewToBack:self.backgroundView];
});
}
- (void)didTransitionToState:(UITableViewCellStateMask)state {
[super didTransitionToState:state];
[self sendSubviewToBack:self.backgroundView];
}
I spoke with an Apple UIKit engineer today at the iOS 7 Tech Talks event in SF, and confirmed that this is an open bug that will be fixed "soon" by Apple.
UPDATE 10/22/13: iOS 7.0.3 fixes this issue.
Workaround
I found an answer in the Apple Developer Forums for a workaround. I've built on that to handle both the case for backgroundView and selectedBackgroundView.
I still see this issue in production iOS7.0.2. This workaround however, is simple and fixes the issue (for me). Drop this code into your custom UITableViewCell subclass.
You can also find it at this gist: https://gist.github.com/idStar/7018104
- (void)layoutSubviews {
[super layoutSubviews];
[self applyEditingModeBackgroundViewPositionCorrections];
}
/**
When using a backgroundView or selectedBackgroundView on a custom UITableViewCell
subclass, iOS7 currently
has a bug where tapping the Delete access control reveals the Delete button, only to have
the background cover it up again! Radar 14940393 has been filed for this. Until solved,
use this method in your Table Cell's layoutSubviews
to correct the behavior.
This solution courtesy of cyphers72 on the Apple Developer Forum, who posted the
working solution here: https://devforums.apple.com/message/873484#873484
*/
- (void)applyEditingModeBackgroundViewPositionCorrections {
if (!self.editing) { return; } // BAIL. This fix is not needed.
// Assertion: we are in editing mode.
// Do we have a regular background view?
if (self.backgroundView) {
// YES: So adjust the frame for that:
CGRect backgroundViewFrame = self.backgroundView.frame;
backgroundViewFrame.origin.x = 0;
self.backgroundView.frame = backgroundViewFrame;
}
// Do we have a selected background view?
if (self.selectedBackgroundView) {
// YES: So adjust the frame for that:
CGRect selectedBackgroundViewFrame = self.selectedBackgroundView.frame;
selectedBackgroundViewFrame.origin.x = 0;
self.selectedBackgroundView.frame = selectedBackgroundViewFrame;
}
}
What we're basically doing here, is resetting the x-origin of these background views to zero at table cell layout time, if they are in editing mode. Why they are translated incorrectly, and why they are above the Apple provided 'Delete' button view is presumably, part of the known issue Apple is working to fix.
I was facing the same issue and finally got solution. Try this:
Instead of calling setBackgroundImage in cellForRowAtIndexPath (Delegate Method). Call it in willDisplayCell:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:#"cellList.png"]];
}
Enjoy Coding
Try below code may be help you.
[youttablecell sendSubviewToBack:yourimageview]

UITextfield at UISearchbar appears different at simulator and on actual iPhone

I managed to customize the look and feel of the UITextfield at UISearchBar using the code below:
for (UIView *subview in [searchBar subviews])
{
if ([subview isKindOfClass:NSClassFromString(#"UISearchBarTextField")]){
[(UITextField *)subview setBackground:[UIImage imageNamed:#"background_searchField.png"]];
[(UITextField *)subview setTextColor:[UIColor redColor]];
}
}
It appears exactly what I wanted when I use the simulator. However, when I tested it on an actual iPhone, the background image was not visible.
Please advice. Many thanks.
Do you have the same exact version of iOS on both simulator and device?
Anyway, don't use this black magic, the UISearchFiled is highly customizable through UIAppearance protocol, check "Customizing Appearance" section in reference.
Same goes for UITextField, you can override text color and background using properties, and do more complicated customization in "Drawing and Positioning Overrides"

Remove or change color of frame around UIWebView document display?

I'm using a UIWebView to display a variety of file types (so I can't use a specialized PDF viewer) embedded into my main view (so I can't use a modal document interaction controller). My main view has a background design that clashes with the light gray frame that appears around documents in the UIWebView. Does anyone know a way to remove that gray frame, make it transparent or change its color?
I'm familiar with and have used the techniques for changing the background color of the UIWebView to avoid a "color flash" while it loads, and for removing the top and bottom shadow that appear when "overscrolling" the web view, but I haven't seen anyone address this gray frame. (It only appears when displaying documents like .doc or .pdf, not when displaying HTML content.) I've hidden all the images that are subviews of the UIWebView's scroll view, so apparently this is coming from somewhere else.
This question was written while iOS 4 was current, but in iOS 5 and later, simply setting the backgroundColor and opaque properties of the UIWebView will remove that gray frame:
myWebView.opaque = NO;
myWebView.backgroundColor = [UIColor clearColor];
You can change WebView's background color by assigning its backgroundColor property:
myWebView.backgroundColor = [UIColor redColor]; // will make red bakground
If you want transparency use [UIColor clearColor] instead. But remember - by making your views tranparent you can worsen app's performance.
Since this has been around for a while I'll just throw some ideas out there.
You may be able to utilize the stringByEvaluatingJavaScriptFromString: method of the UIWebView class to manipulate the document object model if the UIWebView treats the loaded document as a page, but this method has some limitations.
Other than that, the only thing you really have left at your disposal is manipulating the view hierarchy to modify any subviews of the UIWebView, but there may not be anything for you manipulate if the UIWebView class renders the viewer directly rather than creating a hierarchy.
It looks like it is not possible to remove the border from a UIWebView but could you not use CGContextDrawPDFPage() as Apple show here: http://developer.apple.com/library/ios/#samplecode/ZoomingPDFViewer/Introduction/Intro.html
Try this,
self.webview.backgroundColor = [UIColor whiteColor];
for (UIView* subView in [self.webview subviews])
{
if ([subView isKindOfClass:[UIScrollView class]]) {
for (UIView* shadowView in [subView subviews])
{
if ([shadowView isKindOfClass:[UIImageView class]]) {
[shadowView setHidden:YES];
}
}
}
}
This may help you. :-)
You need a bunch of CoreAnimation magic:
- (void) hideShadowInLayer:(CALayer *) layer
{
for (CALayer *l in layer.sublayers) {
l.shadowOpacity = 0;
[self hideShadowInLayer:l];
}
}
- (void) hideShadows
{
[CATransaction begin];
[CATransaction setValue:(id) kCFBooleanTrue forKey:kCATransactionDisableActions];
[self hideShadowInLayer:webView.layer];
[CATransaction commit];
}
You need to perform hideShadows method somewhere AFTER loading your document and while you are scrolling it (I guess scrollViewDidScroll of webView.scrollView.delegate is a good place). You also need to include QuartzCore framework to your project.
What's going on here:
Any view uses something called layer for rendering. Layers can have its own hierarchy and every layer can have its own border and shadow, so the frame that annoying you is the shadow of one of them. Bad thing - UIWebView recreates it while scrolling - so you need to use this method constantly. And I guess shadowOpacity has a default animation attached to it, so you need CATransaction to disable it.

iphone sdk- UIAlertView button with image

can you please tell me if it is possible to use an uiimage view as uialertview button "text"?
i was unable to find the answer googling..
thanks a lot
Yes, it is possible, but I wouldn't recommend it. You'd have to run through the UIAlertView's subviews until you find one that is of the right class, I would assume UIButton, and add your UIImageView on top like this:
for (UIView *v in [myAlertView subviews]) {
if ([v isKindOfClass:[UIButton class]]) {
//IF I AM THE RIGHT BUTTON
[v addSubview:myUIImageView];
}
}
To determine the correct button, you might initially give it some odd text like "foobar5" and test each button to see if that is its text, and if so, remove the text and add the UIImageView.
You can use unicode characters, which are rendered as icons.
I described it here:
Adding Images to UIActionSheet buttons as in UIDocumentInteractionController

Can you tell UIWebView to use a white indicator style?

I'm running into a case where I have in-application HTML documentation that uses a dark background, but the default scroll indicator for UIWebView is getting lost in that background. The following is an example of this:
(source: sunsetlakesoftware.com)
With UIScrollView, which UIWebView resembles in its behavior, you can set the indicatorStyle property to UIScrollViewIndicatorStyleWhite, which results in the desired behavior:
(source: sunsetlakesoftware.com)
I can't seem to find a similar property in the exposed interface for UIWebView. Is there a CSS trick or other way to force the scroll indicator to a lighter style?
Starting iOS 5.0 onwards, one can now customize the scrolling behavior of the web view by accessing the 'scrollview' property to achieve the desired functionality:
webView.scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
If you do want to scan the subviews and attempt to gracefully fail if something changes in the future this currently works:
//set a white scroll bar
for (UIView *subview in [webView subviews]) {
if ([subview isKindOfClass:NSClassFromString(#"UIScroller")] || [subview isKindOfClass:NSClassFromString(#"UIScrollView")]) {
if ([subview respondsToSelector:#selector(setIndicatorStyle:)]) {
[(UIScrollView *)subview setIndicatorStyle:UIScrollViewIndicatorStyleWhite];
}
break;
}
}
Though things could still break in the future if setIndicatorStyle: changes to expect a non-enumerated value... but I doubt that would happen.
Scan the subviews and test for a UIScrollView. You can then programatically set the indicator.
There is no public API for this in the 2.x SDK. File a bug/case/radar asking for it in 3.0.