다른 샘플을 사용하는 방법에 대해 배우고 싶습니다. 성공적인 로그온시 로그인 페이지가 있습니다. 사용자가 테이블보기로 리디렉션 된 다음 테이블보기의 항목 인 경우 사용자는 항목의 세부 정보를 표시하는 세 번째 페이지로 이동합니다.Iphone SDK - UIView에 UITableView 추가하기
첫 페이지는 정상적으로 작동하지만 두 번째 페이지로 이동하면 문제가 발생합니다. 표시된 표에는 제목이 없으며 제목이나 툴바 또는 표 자체의 콘텐츠 이외를 추가 할 수 없습니다. 항목을 클릭하면 아무 일도 일어나지 않습니다. 오류도 없습니다.
나는 프로그래밍에 익숙하지 않고 항상 Java에서 작동하지만 C 언어에 익숙하지는 않습니다 (C의 기본 지식이 있지만). 목표 C는 새로운 것입니다.
다음은 코드입니다.
-(IBAction) login {
RootViewController *rootViewController = [[RootViewController alloc] init];
if([username.text isEqualToString:@"test"]&&[password.text isEqualToString:@"test"]){
[window addSubview:[rootViewController view]];
[window makeKeyAndVisible];
}
else {
loginError.text = @"LOGIN ERROR";
[window addSubview:[viewController view]];
[window makeKeyAndVisible];
}
}
@interface RootViewController : UITableViewController {
IBOutlet NSMutableArray *views;
}
@property (nonatomic, retain) IBOutlet NSMutableArray * views;
- (void)viewDidLoad {
views = [ [NSMutableArray alloc] init];
OpportunityOne *opportunityOneController;
for (int i=1; i<=20; i++) {
opportunityOneController = [[OpportunityOne alloc] init];
opportunityOneController.title = [[NSString alloc] initWithFormat:@"Opportunity %i",i];
[views addObject:[NSDictionary dictionaryWithObjectsAndKeys:
[[NSString alloc] initWithFormat:@"Opportunity %i",i], @ "title", opportunityOneController, @"controller", nil]];
[email protected]"GPS";
}
[super viewDidLoad];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
cell.textLabel.text = [[views objectAtIndex:indexPath.row] objectForKey:@"title"];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController *targetViewController = [[views objectAtIndex:indexPath.row] objectForKey:@"controller"];
[[self navigationController] pushViewController:targetViewController animated:YES];
}
와우, 코드를 게시하기가 정말 어려웠습니다. 잘못된 서식에 대해 사과하지만이 텍스트 편집기의 서식 지정 규칙을 지나칠 수 없습니다.
감사합니다, 네비게이션 기반 응용 프로그램과 샤시
이것은 사람들이 재 형식화하는 것을 보지 못하는 너무 많은 코드입니다. 간단한 자습서를 통해 문제를 좁히고 관련 코드 만 표시하는 방법을 배우십시오. 충분한 정보가 아니라면 사람들은 더 많은 정보를 요구할 것입니다. – DyingCactus
불필요한 코드를 많이 삭제했다고 생각합니다. 더 정리해야하는지 알려주세요. – Shashi