저는 tableView를 포함한 탭 중 하나가있는 tabViewController 인 iPhone 앱을 개발하고 있습니다. 테이블의 객체를 터치하여 특정 객체에 대한 정보가있는 스플래시 화면으로 이동할 수 있습니다. 여기UITableView ObjectAtIndex
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//each table view cell has its own identifier.
static NSString *cellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier] autorelease];
}
NSUInteger row = [indexPath row];
cell.textLabel.text = [sitesArray objectAtIndex:row];
cell.imageView.image = [imagesArray objectAtIndex:row];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
return cell;
}
- (void)viewDidLoad {
NSArray *pageHolder = [[NSArray alloc] initWithObjects:@"CSLP", @"NSLS", @"LSPA", @"SIOP", @"Transfer", nil];
self.pages = pageHolder;
[pageHolder release];
NSArray *sites = [[NSArray alloc] initWithObjects:@"CSLP", @"NSLS", @"LSPA", @"SIOP", @"Transfer Vision Program ", nil];
self.sitesArray = sites;
UIImage *cslp = [UIImage imageNamed:@"CSLP LOGO.png"];
UIImage *nsls = [UIImage imageNamed:@"NSLS LOGO.png"];
UIImage *lspa = [UIImage imageNamed:@"LSPA LOGO.png"];
UIImage *siop = [UIImage imageNamed:@"SIOP LOGO.png"];
UIImage *transfer = [UIImage imageNamed:@"TRANSFER LOGO.png"];
NSArray *images = [[NSArray alloc] initWithObjects: cslp, nsls, lspa, siop, transfer, nil];
[sites release];
self.imagesArray = images;
UIButton* modalViewButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[modalViewButton addTarget:self action:@selector(modalViewAction:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *modalBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:modalViewButton];
self.navigationItem.rightBarButtonItem = modalBarButtonItem;
[modalBarButtonItem release];
[self.table reloadData];
}
그리고 내 didSelectRowAtIndexPath의 방법 didSelectRowAtIndexPath 방법에 objectAtIndex의 최초의 호출에
-(void) tableView:(UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath
{
NSInteger row = [indexPath row];
NSMutableDictionary *rowData = [table objectAtIndex:indexPath.row];
UIViewController *targetViewController = [rowData objectForKey:kViewControllerKey];
if (!targetViewController)
{
// The view controller has not been created yet, create it and set it to our menuList array
NSString *viewControllerName = [[pages objectAtIndex:indexPath.row] stringByAppendingString:@"ViewController"];
targetViewController = [[NSClassFromString(viewControllerName) alloc] initWithNibName:viewControllerName bundle:nil];
[rowData setValue:targetViewController forKey:kViewControllerKey];
[targetViewController release];
}
SSARC_App_2AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.orgsNavigationController pushNavigationItem:targetViewController animated:YES];
[delegate release];
}
응용 프로그램이 충돌입니다 :
는 여기에 내가 배열있는 tableView를 설정하는 방법입니다. 콘솔 상태 :
010-11-22 12 : 50 : 17.113 SSARC 앱 2 43,470 : 207] - [jQuery과 objectAtIndex :] 인스턴스에 보내 인식 선택기 0x601e800 2010-11-22 12 : 50 : 17.116 SSARC 앱 2 43,470 : 207] * 사정 때문에 캐치되지 않는 예외 'NSInvalidArgumentException'응용 프로그램 종료 : '- [jQuery과 objectAtIndex :] 인식 선택기 인스턴스 0x601e800 전송' * 처음 던질 때 스택 호출 :
이제 "UITableView가 ObjectAtIndex에 응답하지 않을 수 있습니다"라는 경고가 나타납니다. 나는 이것이 여기에서 주요한 문제라고 가정하고있다. 그러나 나는 그것을 해결하는 방법을 확신 할 수 없다. 흥미롭게도 나는이 문제를 어디에서나 찾아 보았고 어느 곳에서도 찾을 수 없었기 때문에 누군가가이 문제에 부딪쳤거나 해결할 수 있는지 알고 싶다. 어떤 충고라도 잘 될 것입니다. 더 많은 정보가 필요하면 알려주세요.
나는 내 자신에 대한 몇 가지 코딩을하고있다 그리고 나는 그것이 오류 또는 경고없이 컴파일 오긴했는데,하지만 여전히 충돌합니다. 현재 이것은 내가 가지고있는 것입니다 :
NSMutableDictionary *rowData = [self.menuList objectAtIndex:indexPath.row];
UIViewController *targetViewController = [rowData objectForKey:kViewControllerKey];
if (!targetViewController)
{
// The view controller has not been created yet, create it and set it to our menuList array
NSString *viewControllerName = [[pages objectAtIndex:indexPath.row] stringByAppendingString:@"ViewController"];
targetViewController = [[NSClassFromString(viewControllerName) alloc] init];//WithNibName:viewControllerName bundle:nil];
NSLog(@"targetViewController: %@", targetViewController);
[rowData setValue:targetViewController forKey:kViewControllerKey];
[targetViewController release];
}
SSARC_App_2AppDelegate *delegate = (SSARC_App_2AppDelegate*)[[UIApplication sharedApplication] delegate];
[[delegate orgsNavigationController] pushViewController:targetViewController animated:YES];
[delegate release];
delegate = nil;
디버거가보고하는 문제는 'viewControllerName'이 (가) '범위를 벗어났습니다.'라는 것입니다. 나는 NSLog를 사용할 때 viewControllerName이 초기화되기 때문에 그 의미가 무엇인지 이해하지 못합니다. 그게 제가 말하는 수업을 찾을 수 없다는 뜻입니까? 저에게 알려주세요.
'sitesArray'의 속성 선언을 표시 할 수 있습니까 – vikingosegundo
'sitesArray','imagesArray' 및'pages'의 속성 선언을 표시 할 수 있습니까 – vikingosegundo
안녕하세요! 이러한 배열의 속성 정의는 다음과 같습니다. @property (nonatomic, retain) NSArray * pages; @property (비 원자력, 보유) NSArray * imagesArray; @property (비 원자력, 보유) NSArray * sitesArray; – Baker