티스토리 뷰
IB에서 일반 View를 생성하여 UITextField를 추가하여 정보를 입력 받는 방식만 써오다가
//
// CWTextInputTableViewCell.h
// RoadDesigner
//
// Created by Changwook Jeong on 11. 3. 4..
// Copyright 2011 GNR Technology Inc. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CWTextInputTableViewCell : UITableViewCell {
UILabel *_mainLabel;
UITextField *_inputField;
}
@property (nonatomic, retain) UILabel *mainLabel;
@property (nonatomic, retain) UITextField *inputField;
@end
//
// CWTextInputTableViewCell.m
// RoadDesigner
//
// Created by Changwook Jeong on 11. 3. 4..
// Copyright 2011 GNR Technology Inc. All rights reserved.
//
#import "CWTextInputTableViewCell.h"
@implementation CWTextInputTableViewCell
@synthesize mainLabel = _mainLabel;
@synthesize inputField = _inputField;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code.
_inputField = [[UITextField alloc] initWithFrame:CGRectMake(10.0, 0.0, self.bounds.size.width-30.0, self.bounds.size.height)];
_inputField.font = [UIFont systemFontOfSize:17.0];
_inputField.textAlignment = UITextAlignmentLeft;
_inputField.textColor = [UIColor blackColor];
_inputField.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
_inputField.leftViewMode = UITextFieldViewModeAlways;
_inputField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
_inputField.clearButtonMode = UITextFieldViewModeWhileEditing;
[self.contentView addSubview:_inputField];
_mainLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 0.0, 90.0, self.bounds.size.height)];
_mainLabel.font = [UIFont systemFontOfSize:17.0];
_mainLabel.textAlignment = UITextAlignmentLeft;
_mainLabel.adjustsFontSizeToFitWidth = YES;
_mainLabel.textColor = [UIColor blackColor];
//_mainLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
[_inputField setLeftView:_mainLabel];
self.selectionStyle = UITableViewCellSelectionStyleNone;
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state.
}
- (void)dealloc {
[_mainLabel release];
[_inputField release];
[super dealloc];
}
@end
* 사용할때는 아래와 같이 사용하면 된다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"Cell";
CWTextInputTableViewCell *cell =
(CWTextInputTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[[CWTextInputTableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
}
cell.mainLabel.text = @"mainLabel";
return cell;
}
'iOS SDK' 카테고리의 다른 글
Customize UITabBar in iOS5 (0) | 2011.10.21 |
---|---|
iOS5에 추가된 트위터 관련 API 사용방법 (0) | 2011.10.17 |
Navigation Bar Back 버튼의 Text 변경 하기 (0) | 2011.06.03 |
UISearchBar를 테이블뷰의 상단에 위치했을때 자동으로 숨기기 (0) | 2011.06.03 |
URL스키마를 이용한 다른 어플리케이션 실행하기 (0) | 2011.04.19 |
- Total
- Today
- Yesterday
- UITableView
- MappingModel
- badgeValue
- distribution
- AVAudioSessionDelegate
- 애플 문서
- AVAudioSessionInterruptionNotification
- objective-c
- AVAudioSession
- beginInterruption
- ARX
- CAD
- iPhone
- ManagedObjectModel
- 배포
- C++
- setSelectionIndicatorImage
- iOS5
- UINavigationBar
- xcode
- MFC
- progressively
- setBackGroundImage
- endInterruption
- apns
- object-c
- ios
- C
- SDK
- git hub
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |