iPhone 응용 프로그램 개발을 처음 사용합니다. UITableView를 사용하는 방법을 이해하려고합니다. 난iPhone : UITableView, 표 내용 끌기가 발생합니다.
는 간단한 코드 작성 :
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1 ;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease];
}
cell.textLabel.text = @"Hello";
return cell;
}
UITable 보여줍니다 컨텐츠를,하지만 난 드래그 테이블 내용을 해요 경우 내 응용 프로그램이 종료됩니다.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1 ;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [hello count] ;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease];
}
cell.textLabel.text = [hello objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:NO];
NSLog(@"Selected") ;
}
- (void) awakeFromNib
{
hello = [[NSArray alloc] initWithObjects:@"hello", @"world", @"end", nil];
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
내용이 표시되고 내가 항목을 선택하고있어 만약 내가 받고 있어요 :
[Session started at 2010-03-16 19:21:48 +0200.]
2010-03-16 19:21:52.295 ViewTest[1775:207] *** -[ViewTestViewController respondsToSelector:]: message sent to deallocated instance 0x3911ec0
내가 총 해요 내가 배열로 모든 것을 시도 http://www.youtube.com/watch?v=TucTVJVhSD0
: 당신은 비디오를 볼 수 있습니다 iPhone 프로그래밍에 익숙하지 않습니다. 그리고 내가하는 모든 것을 보았습니다. 난 그냥 응용 프로그램을 종료하게 될뿐입니다.
아니요, 프로토콜을 구현하지 않습니다. 나는 dataSource를 IB의 ViewTestViewController에 설정했다. #import @interface ViewTestViewController : UIViewController { \t NSArray * hello; } @end –
kesrut