0
私のアプリケーションでは、テキストをUITextView
に貼り付け、UITableView
の行ごとに表示する必要がありますが、アプリケーション内にテキストを貼り付けたときに余分な未使用行の下の行に移動します。 。イメージでは、TextViewの一番上のテキストを入力して、それが下に移動するたびに空の行を作成することがわかります。テキストを貼り付けて余分なスペースを作成する
Heres my code。
-(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];
}
cell.textLabel.text = [NSString stringWithFormat:@"%@",[listArray objectAtIndex:indexPath.row]];;
return cell;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [listArray count];
}
-(void)textViewDidChange:(UITextView *)textView{
listArray=[[NSMutableArray alloc]initWithArray:[textView.text componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]]];
[self.tableView reloadData];
}
これは私が貼りすべてのために発生しませんが、私はアプリケーションに入力する必要があるテキストの、基本的には、1つのメイン部分のために起こるん。
私は、最終的なテキストのために使用されていない変数の警告を取得することにより、余分なスペースを削除することができます。 – vype
あなたがこの変数をどこでも使用しなかったので、 – Jamil
私はtextViewに変更してもそれは変わらない。 – vype