Detect the specific device touch model
[[UIDevice currentDevice] platformType] // ex: UIDevice4GiPhone
[[UIDevice currentDevice] platformString] // ex: @"iPhone 4G"
Labels:
iphone SDK,
platform,
type
Clear UIWebView content
[webView loadHTMLString:@"<html><head></head><body></body></html>" baseURL:nil];
Labels:
empty,
html,
iphone SDK,
white
Define Maximum Characters in Textfield
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSUInteger newLength = [textField.text length] + [string length] - range.length;
return (newLength > 80) ? NO : YES;
}
Change UITextField’s Placeholder Color
[self.MyTextField setValue:[UIColor darkGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
Labels:
iphone SDK,
place holder,
textfield
Set Rounded Corner to Image
UIImageView * roundedView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"wood.jpg"]];
// Get the Layer of any view
CALayer * l = [roundedView layer];
[l setMasksToBounds:YES];
[l setCornerRadius:10.0];
// You can even add a border
[l setBorderWidth:4.0];
[l setBorderColor:[[UIColor blueColor] CGColor]];
Labels:
border,
image,
iphone SDK,
round
How to post Tweets with iOS5
- Add Twitter framework to your project
- #import "Twitter/TWTweetComposeViewController.h"
- Add this code:
TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];
[twitter setInitialText:@"It's really that simple!"];
[twitter addImage:[UIImage imageNamed:@"twitter.png"]];
[self presentViewController:twitter animated:YES completion:nil];
twitter.completionHandler = ^(TWTweetComposeViewControllerResult res) {
if(res == TWTweetComposeViewControllerResultDone)
{
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Succes!" message:@"Your Tweet was posted succesfully" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}else if(res == TWTweetComposeViewControllerResultCancelled)
{
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your Tweet was not posted" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
[self dismissModalViewControllerAnimated:YES];
};
Labels:
ios5,
iphone SDK,
twitter
Disable or Hide Button in UIActionSheet
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Share"
delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil
otherButtonTitles:@"Send Message (SMS)", @"Send E-Mail", @"Print", @"Twitter", nil];
[actionSheet showInView:self.view];
for(UIView *v in [actionSheet subviews])
{
if([[v description] hasPrefix: @"<UIThreePartButton"] )
{
if ([v respondsToSelector:@selector(title)])
{
NSString* title = [v performSelector:@selector(title)];
if ([title isEqualToString:@"Twitter"])
{
//v.hidden = YES;
((UIButton*)v).enabled = NO;
}
}
}
}
[actionSheet release];
Labels:
actionsheet,
iphone SDK
Subscribe to:
Posts (Atom)