Translate
2013年4月22日 星期一
UIActivityViewController googleplus
參考link
Shareing Example
Shareing Example
NSString *shareString = @"CapTech is a great place to work.";
UIImage *shareImage = [UIImage imageNamed:@"Icon.png"];
NSURL *shareUrl = [NSURL URLWithString:@"http://www.captechconsulting.com"];
NSArray *activityItems = [NSArray arrayWithObjects:shareString, shareImage, shareUrl, nil];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:activityViewController animated:YES completion:nil];
[activityViewController setCompletionHandler:^(NSString *activityType, BOOL completed)
{
NSLog(@"Activity is %@", activityType);
NSLog(@"Completed Status = %d", completed);
if (completed)
{
}
else
{
}
}];
SLComposeViewController
參考1
參考2
參考中文網站
首先先加入Social.framework跟Accounts.framework
有三種可以使用
SLServiceTypeTwitter;
SLServiceTypeFacebook;
SLServiceTypeSinaWeibo;
分享facebook
參考2
參考中文網站
首先先加入Social.framework跟Accounts.framework
有三種可以使用
SLServiceTypeTwitter;
SLServiceTypeFacebook;
SLServiceTypeSinaWeibo;
分享facebook
SLComposeViewController *fbController=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
{
SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){
[fbController dismissViewControllerAnimated:YES completion:nil];
switch(result){
case SLComposeViewControllerResultCancelled:
default:
{
NSLog(@"Cancelled.....");
}
break;
case SLComposeViewControllerResultDone:
{
NSLog(@"Posted....");
}
break;
}};
[fbController addImage:[UIImage imageNamed:@"1.jpg"]];
[fbController setInitialText:@"Check out this article."];
[fbController addURL:[NSURL URLWithString:@"http://soulwithmobiletechnology.blogspot.com/"]];
[fbController setCompletionHandler:completionHandler];
[self presentViewController:fbController animated:YES completion:nil];
}
2013年4月16日 星期二
Custom Fonts
參考網站
在專案裡面需要用到ttf的字型
所以記錄一下
加入the .ttf檔案到專案裡

確定Add to targets是勾起來的

點選.ttf檔確定右手邊的Target Memvership是打勾的

在回專案的TARGETS->Build Phases->Copy Bundle Resources

最後在專案的info.plist增加Fonts provided by application並加上.ttf的檔案名稱

然後取得.ttf的全名

使用方法
在專案裡面需要用到ttf的字型
所以記錄一下
加入the .ttf檔案到專案裡

確定Add to targets是勾起來的

點選.ttf檔確定右手邊的Target Memvership是打勾的

在回專案的TARGETS->Build Phases->Copy Bundle Resources

最後在專案的info.plist增加Fonts provided by application並加上.ttf的檔案名稱

然後取得.ttf的全名

使用方法
NSLog(@"vagrounded-bold.ttf is %@",
[UIFont fontNamesForFamilyName:@"VAGRounded-Bold"]
);
NSLog(@"vagrounded-thin.ttf is %@",
[UIFont fontNamesForFamilyName:@"VAGROUNDED-Thin"]
);
UILabel *lab = [UILabel new];
[lab setFrame:CGRectMake(50, 50, 100, 30)];
UIFont *swissLight = [UIFont
fontWithName:@"VAGRounded-Bold"
size:20.0f];
[lab setFont:swissLight];
[lab setText:@"GodCam"];
[self.view addSubview:lab];
UILabel *lab2 = [UILabel new];
[lab2 setFrame:CGRectMake(50, 100, 100, 30)];
UIFont *swissLight2 = [UIFont
fontWithName:@"VAGROUNDED-Thin"
size:20.0f];
[lab2 setFont:swissLight2];
[lab2 setText:@"GodCam"];
[self.view addSubview:lab2];
2013-04-17 13:48:20.635 UseTTF[787:c07] vagrounded-bold.ttf is (
"VAGRounded-Bold"
)
2013-04-17 13:48:20.636 UseTTF[787:c07] vagrounded-thin.ttf is (
"VAGROUNDED-Thin"
)
2013年4月14日 星期日
objective-c type
今天在查objective-c的資料形態
發現一個網站介紹的很仔細
參考網站
主要是為了要查long long怎麼format
我個人只有用過每個format的第一種方法
另外id的format我是都用%@
發現一個網站介紹的很仔細
參考網站
主要是為了要查long long怎麼format
我個人只有用過每個format的第一種方法
另外id的format我是都用%@
2013年4月2日 星期二
2013年4月1日 星期一
UIImageView zoom
專案裡需要一個小功能
針對圖片放大縮小
花了點時間找了些資料
實作的時候卻發現在zoom的時候圖片怪怪的
原來魔鬼藏在細節裡
大致上最重要的一句話就是
//如果不加这句的话
[imageView setFrame:CGRectMake(0, 0, scrollView.frame.size.width, scrollView.frame.size.height)];
//那么正常拖动是可以的,但是如果zoom了 就会有问题
全整的程式碼
scrollViewController.h
記得加上UIScrollViewDelegate
這樣才有拖拉放大縮小的效果
scrollViewController.m
針對圖片放大縮小
花了點時間找了些資料
實作的時候卻發現在zoom的時候圖片怪怪的
原來魔鬼藏在細節裡
大致上最重要的一句話就是
//如果不加这句的话
[imageView setFrame:CGRectMake(0, 0, scrollView.frame.size.width, scrollView.frame.size.height)];
//那么正常拖动是可以的,但是如果zoom了 就会有问题
全整的程式碼
scrollViewController.h
記得加上UIScrollViewDelegate
這樣才有拖拉放大縮小的效果
#import
@interface scrollViewController : UIViewController {
IBOutlet UIScrollView *scrollView;
UIImageView *imageView;
}
@end
scrollViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
[scrollView setMinimumZoomScale:1.0];
[scrollView setMaximumZoomScale:5.0];
scrollView.delegate = self;
scrollView.bounces = NO;
[scrollView setShowsHorizontalScrollIndicator:NO];
[scrollView setShowsVerticalScrollIndicator:NO];
[scrollView setBackgroundColor:[UIColor blackColor]];
imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"test.jpg"]];
[imageView setContentMode:UIViewContentModeScaleAspectFit];
//如果不加这句的话
[imageView setFrame:CGRectMake(0, 0, scrollView.frame.size.width, scrollView.frame.size.height)];
//那么正常拖动是可以的,但是如果zoom了 就会有问题
//zoom发生后会把frame变成当前显示大小[imageview默认大小 屏幕显示大小 如是全屏则就是全屏大小] zoom变化导致frame同步改变了image的size 大小为frame大小
//image 的size改变后导致self.scrollView.contentSize 变成了frame的大小 从而contentSize变小了 无法实现正常拖动。
//然后根据zoom缩放比例变化。而不是根据实际图片大小。这么导致zoom后就无法拖动了[因为frame大小]
scrollView.contentSize = imageView.frame.size;
[scrollView addSubview:imageView];
[scrollView setZoomScale:scrollView.minimumZoomScale];
}
#pragma mark - UIScrollViewDelegate
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)_scrollView {
return imageView;
}
訂閱:
意見 (Atom)