uitextfieldのキーボードを閉じる
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.view.subviews enumerateObjectsUsingBlock:^(UIView* obj, NSUInteger idx, BOOL *stop) {
if ([obj isKindOfClass:[UITextField class]]) {
[obj resignFirstResponder];
}
}];
}
アプリで電話、地図、飛ぶように。
アプリで電話、地図、飛ぶように。
漢字があるばあい
NSString *addressText = [_item.location stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSString* urlText = [NSString stringWithFormat:@"http://maps.apple.com/maps?q=%@",addressText];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];
セル高さの計算
CommentItem *comment = _comments[indexPath.row];
UILabel *contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 5 , [Common screenSize].width - 70, 35)];
contentLabel.font = DEFAULT_FONT(16);
contentLabel.numberOfLines = 0;
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:comment.message];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:8];//行間
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [comment.message length])];
contentLabel.attributedText = attributedString;
[contentLabel sizeToFit];
NSLog(@"%f", contentLabel.frame.size.height);
contentLabel.frame.size.height
//これは行間