Note that there are some explanatory texts on larger screens.

plurals
  1. POUISwitch Graphical Artifact
    text
    copied!<p>i have made a normal UISwitch programmatically in objective c inside a UITableViewCell and when i go to view it in the simulator i see this:</p> <p><img src="https://i.stack.imgur.com/Mn4Mo.png" alt="Graphics Glitch"></p> <p>Why is it happening and how can i fix it?</p> <p>Here is the code for how i am implementing it:</p> <p>UISwitch Class:</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; @interface SwitchCell : UITableViewCell + (SwitchCell*)SwitchCellMake; @end @implementation SwitchCell - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // Initialization code } return self; } + (SwitchCell*)SwitchCellMake{ SwitchCell * newSwitchCell = [[SwitchCell alloc]init]; UISwitch * cellSwitch = [[UISwitch alloc] init]; [newSwitchCell.contentView addSubview:cellSwitch]; [cellSwitch setCenter:CGPointMake(600, 30)]; return newSwitchCell; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated{ [super setSelected:selected animated:animated]; } @end </code></pre> <p>ViewDidLoad:</p> <pre><code>- (void)viewDidLoad{ [super viewDidLoad]; [arySwitchCells addObject:[SwitchCell SwitchCellMake]]; } </code></pre> <p>And the cellForRowAtIndexPath method:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ SwitchCell *cellSwitchCell = (SwitchCell *)[tableView dequeueReusableCellWithIdentifier:@"SwitchCell"]; cellSwitchCell = [arySwitchCells objectAtIndex:indexPath.row]; return cellSwitchCell; } </code></pre>
 

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