gpt4 book ai didi

iphone - 尝试编辑单元格时 UITableView 崩溃

转载 作者:行者123 更新时间:2023-12-02 17:24:03 25 4
gpt4 key购买 nike

我有某种表单,其中包含表格 View 中的 5 个自定义单元格。这是代码:

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;}

\- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 5;
}

\- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

NSLog(@"in here");
static NSString *MyIdentifier = @"MyIdentifier";

FreeSignupCell *cell = (FreeSignupCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
NSLog(@"shazam");
cell = [[[FreeSignupCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}

switch (indexPath.row) {
case 0:
NSLog(@"index 0");
[cell setLabelContent:@"First Name"];
//self.firstName = [cell getText];
break;
case 1:
NSLog(@"index 1");
[cell setLabelContent:@"Last Name"];
//self.lastName = [cell getText];
break;
case 2:
NSLog(@"index 2");
[cell setLabelContent:@"Company (optional)"];
//self.company = [cell getText];
break;
case 3:
NSLog(@"index 3");
[cell setLabelContent:@"Website (optional)"];
[cell setText: @"http://"];
//self.website = [cell getText];
break;
case 4:
NSLog(@"index 4");
[cell setLabelContent:@"E-mail"];
//self.email = [cell getText];
break;
default:
[cell setLabelContent:@"E-mail"];
}

return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 70.0;
}

问题是,当我编辑第一个字段时,快速滚动到最后一个字段,应用程序因 objc_mssend 错误而崩溃。

有什么想法吗?

最佳答案

另一个问题...这是我如何从页面获取数据

-(void) SignupAction {

//Fetching signup data from signup form
NSIndexPath *path = [NSIndexPath indexPathForRow:0 inSection:0];
FreeSignupCell *cell = (FreeSignupCell *)[self.tableView cellForRowAtIndexPath:path];
self.firstName = [cell getText];

path = [NSIndexPath indexPathForRow:1 inSection:0];
cell = (FreeSignupCell *)[self.tableView cellForRowAtIndexPath:path];
self.lastName = [cell getText];

path = [NSIndexPath indexPathForRow:2 inSection:0];
cell = (FreeSignupCell *)[self.tableView cellForRowAtIndexPath:path];
self.company = [cell getText];

path = [NSIndexPath indexPathForRow:3 inSection:0];
cell = (FreeSignupCell *)[self.tableView cellForRowAtIndexPath:path];
self.website = [cell getText];

path = [NSIndexPath indexPathForRow:4 inSection:0];
cell = (FreeSignupCell *)[self.tableView cellForRowAtIndexPath:path];
self.email = [cell getText];

//JSON Dictionaries require parameters that are not null
if (self.firstName == nil) {
self.firstName = @"";
}
if (self.lastName == nil) {
self.lastName = @"";
}
if (self.company == nil) {
self.company = @"";
}
if (self.website == nil) {
self.website = @"";
}
if (self.email == nil) {
self.email = @"";
}

当我按下页面上的“注册”按钮时,我只看到网站和电子邮件字段。发生的情况是,当我记录变量时,只有电子邮件和网站存在,其他的是@“”。发生了什么事?

关于iphone - 尝试编辑单元格时 UITableView 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1879616/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com