Notification icon - iphone

How can i add notification icon on a button..I m able to add it on application icon but not on the button...Help me pls...
UIApplication *application = [UIApplication sharedApplication];
application.applicationIconBadgeNumber = 1; // set to any integer
I m using this code..
Thank you....

You can use some custom views. Here is the nice one: link

While some classes may have private APIs to add such icons, I believe the only class that publicly supports it is UITabBarItem.
Your best bet would be to create your own custom view class that draws the icon appropriately, and then layer it on top of your button (e.g. by adding it as a subview of the button at the proper position).

Related

MFMessageComposeViewController Semi-Transparent Keyboard

I'm trying to initiate a MFMessageComposeViewController with a semi transparent keyboard. I would like to make it as transparent as I want, but I don't think we are allowed to do that from the reading that I've done.
How would you set the property of the UIKeyboard when you create the MFMessageComposeViewController?
Many Thanks!
You do not. From the documentation:
Important The message composition interface itself is not customizable and must not be modified by your application. In addition, after presenting the interface, your application is unable to make further changes to the SMS content. The user can edit the content using the interface, but programmatic changes are ignored. Thus, you must set the values of content fields, if desired, before presenting the interface.
You are not supposed to change this interface, since UIKeyboard is private and the textfields on this view are not accessible by you. Attempting to access and modify this textfield via the view hierarchy might get your app rejected in the app store.
Setting the keyboardAppearance property of your text field or text view to UIKeyboardAppearanceAlert will change the keyboard to the transparent keyboard.
I heard that there's only two styles available in the public API:
[textView setKeyboardAppearance:UIKeyboardAppearanceAlert];
[textView setKeyboardAppearance:UIKeyboardAppearanceDefault];
But you can use private API methods to retrieve the keyboard implementation:
id keyboardImpl = [objc_getClass("UIKeyboardImpl") sharedInstance];
And Make it less opaque,
[keyboardImpl setAlpha:0.8f];
Tint it,
UIView *tint = [[UIView alloc] initWithFrame:[keyboardImpl frame]];
[tint setBackgroundColor:[UIColor colorWithRed:0.0f green:0.0f blue:1.0f alpha:0.3f]];
[tint setUserInteractionEnabled:NO];
[[keyboardImpl superview] insertSubview:tint aboveSubview:keyboardImpl];
[tint release];
Or even flip it:
[[keyboardImpl window] setTransform:CGAffineTransformMakeScale(-1.0f, 1.0f)];
Hope it was the solution for your problem.

Is it possible to overlap the status bar with content in iOS?

Is it possible for content in a view to overlap the status bar in iOS? I don't want to cover the whole status bar - just have a graphic extend a few pixels into it.
Are there any examples of this in the store now? Or does the HIG prohibit it?
I've seen examples of apps that place their own content in the iOS status bar. Reeder is perhaps the most popular example of this. But in Reeder, the content is contained entirely within the status bar.
You can use UIWindow,
UIApplication *app = [UIApplication sharedApplication];
UIWindow *overlapView = [UIWindow new];
overlapView.windowLevel = UIWindowLevelStatusBar + 1;
overlapView.frame = app.statusBarFrame; // you can set any size of frame you want
P.S. instance of UIWindow is set hidden = YES by default, so you should set hidden = NO when you want to display the overlapView;

How to detect the user click a hyper-link

My app will display some text, and I want to make the hyper-link be able to be clicked. I have some questions about this feature.
How do I parse the text to be aware this is a link?
Once a user click the link, I don't want the OS to switch to Safari and open the link, this is very bad because the user can not go back to my application. So I want to open the link within my application. As soon as the user click the link, my app will present a view modally to display the web content. Any advice would be appreciated.
You probably want to subclass UILabel. When you change the text, have it try to see if the text is a hyperlink, if it is, set it to enable user interaction and change the text color to blue. When the user taps on the link, send a message to the main view controller (Possibly through delegation) to open the link.
to display web content in your app, look into UIWebView.
If your text can be formatted as html with hyperlinks (<a> tags), you could use a UIWebView to display it.
The UIWebViewDelegate's webView:shouldStartLoadWithRequest:navigationType: method is called when a user taps a link. Usually you would make your controller implement this method, and set the UIWebView's delegate to the controller.
You're going to want to check out a Github project called LRLinkableLabel.
It will auto-detect any URLs that are inside the .text property.
You can use it like so:
LRLinkableLabel *label = [[LRLinkableLabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 20.0)];
label.delegate = self;
label.text = #"Check out http://dundermifflin.com to find some great paper deals!";
Then just make sure self implements this method:
- (void) linkableLabel:(LRLinkableLabel *)label clickedButton:(UIButton *)button forURL:(NSURL *)url {
[[UIApplication sharedApplication] openURL:url];
}
You can also use the linkColor and textColor properties to configure the appearance of the label. From this point you can use it just like any other UILabel.
Remember to set the delegate to nil when you're all done to make sure everything is all cleaned up.
Hope this helps.

Write some text in (or on) UIStatusBar

I know, it's a strange question ^^,
I would like to know if there is a way to write some text in (or on) the UIStatusBar. In particular I want to write some text on the Status Bar when the user press a UIButton.
Thanks!
I'm not sure if you can draw directly into the status bar, but you should be able to draw on top of it in a custom view. You can get the status bar's frame using:
CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
And you can get the application's main window (presumably the status bar's superview) using:
UIWindow *mainWindow = [[UIApplication sharedApplication] keyWindow];
You should be able to add your custom view directly to the key window in the status bar's frame. For an example of an app that appears to "modify" the status bar, take a look at Reeder.
No, the status bar is a system-controlled element. It's content cannot be modified by a third-party application.
Check out this work in progress: https://github.com/maciekish/APStatusBarExtensions
MTStatusBarOverlay is what you want :
https://github.com/myell0w/MTStatusBarOverlay
Definitely the easier to use !

Displaying Map ONLY when the button is clicked in Xcode

I am developing an iPhone application using XCode and I am kinda stuck with the functionality described in the subject of this post.
I want the map(using MapKit) to only load and display after I click a button. So, what code should I have under that my "(IBAction) showMap" function?
Whatever I could find online talks about unhiding the map. I want to only load the map when a button is clicked rather than loading the map in the background and simply unhiding it the click of the the button. Thanks !
~Susanth
Your button click should open a new view, which contains Map. Since that view does not exist until it's loaded (viewDidLoad, viewWillAppear), you are not loading map or displaying it beforehands.
- (IBAction)showMap:(id)sender
{
self.mapController = [[MyMapViewController alloc]
initWithNibName:#"MyMapViewController" bundle:nil];
[self.mainView addSubview:mapController.view];
}
Many ways to do it... It takes time to load a map, so you might still consider loading it at background. Looks better (faster) for end-user.
use the below concept.
-(IBAction) showMap:(id)sender
{
// Add your Map to current view
[self.view addsubview:YOUR_MAPVIEW];
}
-(IBAction) hideMap:(id)sender
{
[YOURMAPVIEW removeFromSuperView];
}
Here you can create the MapView either from XIB file or by writing code.
Hope this helps.
Jim.