안녕하세요, 텍스트 필드, tableview 및 단추가있는 응용 프로그램을 만들려고합니다. 버튼을 누르면 텍스트 필드의 정보가 테이블 뷰에 추가됩니다. 이 튜토리얼을 언제 찾을 수 있습니까? 나는 책에 하나를 가지고 있지만 그것을 찾을 수 없습니다. 미리 감사드립니다. 하는 .m텍스트 필드에서 테이블보기로 정보로드
- (void)viewDidLoad{
[super viewDidLoad];
self.textonota.delegate = self;
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return NO;
}
- (IBAction)AddNota:(id)sender {
[arrayNota addObject: textonota.text];
[tableNota reloadData];
}
//TableView------------------------------------
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [arrayNota count];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (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] init];
}
cell.textLabel.text = [arrayNota objectAtIndex: indexPath.row];
return cell;
}
//----------------------------------------------
@end
의 .H
@interface BlockNotasViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
IBOutlet UITableView *tableNota;}
@property (strong, nonatomic) IBOutlet UITextField *textonota;
@property (nonatomic, retain) IBOutlet UITableView *tableNota;
@property (nonatomic, strong) NSMutableArray * arrayNota;
- (IBAction)AddNota:(id)sender;
@end
코드의
코드 : 여기에 지금까지 내 코드입니다
더 이상의 오류는 없지만 버튼은 아무 것도 수행하지 않습니다.
예, 어떻게 할 지에 대한 아이디어를 제공하지만 제가 따라야 할 가이드를 알고 있습니까? – darkjuso
내가 문제가있는 것들은 셀에있는 배열이고 버튼에 무엇을 넣어야합니까? 오류의 경우 – darkjuso
, 현재 클래스가 UITableView의 하위 클래스입니까? UIView UITableView의 대리자 메서드를받는 것처럼 보입니다. 다음은 UITableView 튜토리얼입니다 : http : //www.iosdevnotes.com/2011/10/uitableview-tutorial/ – coolbeet