Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here You should make the Change in Your Code like As</p> <p><strong>Answer-1:- If you want to customize cells by simply adding additional views, you should add them to the content view .so they will be positioned appropriately as the cell transitions into and out of editing mode.</strong></p> <p><strong>Answer-2</strong> Crash Reason:- Because you were not returning UITableViewCell.As Crash Log ItSelf Explain The same <code>*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'</code></p> <p>Answer 3 -For this <code>My understanding is that the cell has to be return first before I can allocate some value to it</code>.Here For this Line i would say you are totally wrong simply think. <code>can you put mango inside the basket even if you don't have that basket.means you will need that</code> . so the same concept is here whenever you are going to add something like <code>textfield</code> the <code>TableCell</code> you need to <code>create(allocate)</code> that first and then you can add any object over that <code>tableCell</code> and finally return that <code>tableCell</code>As You would see inside the <code>CellForRowAtIndexPath</code> method. I think you clear now.</p> <p>For The UISwitch you were adding it over the <code>self.view</code> means <code>controller's view</code>.see your code <code>[self.view addSubview:]</code> showing that switch over the mainView(conrtoller' view) rather Shwoing over the <code>tableViewCell</code> .and for the TextField it was not working because of this line <code>cell = (UITableViewCell *)[field0 superview];</code>it's totally wrong.</p> <p>Just for your kind Information see below code.</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; } cell.selectionStyle = UITableViewCellSelectionStyleNone; // VERY IMPORTANT if(indexPath.section == 2) { if (indexPath.row == 0) { UITextField* thisTextField =[[UITextField alloc] initWithFrame:CGRectMake(originX, originY, width ,hieght)];//pass the co-ordinate. [thisTextField setBackgroundColor:[UIColor clearColor]]; [thisTextField setTag:indexPath.row];//here by setting this you can access further it thisTextField.delegate= self; [[cell contentView] addSubview:thisTextField]; // If you want to customize cells by simply adding additional views, // you should add them to the content view . // so they will be positioned appropriately as the cell transitions into and out of editing mode. } return cell; </code></pre> <p>}</p> <p>I would suggest you should start from the basic of view Hierarchy and UITableView.</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload