Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot assign to self out of a method in the init family?
    primarykey
    data
    text
    <p>I am using self like "<code>self = [super init];</code>", the following code give me an error "<code>cannot assign to self out of a method in the init family</code>"</p> <pre><code>- (id)showDropDown:(UIButton *)b:(CGFloat *)height:(NSArray *)arr:(NSString *)direction { btnSender = b; animationDirection = direction; self = [super init]; if (self) { // Initialization code CGRect btn = b.frame; self.list = [NSArray arrayWithArray:arr]; if ([direction isEqualToString:@"up"]) { self.frame = CGRectMake(btn.origin.x, btn.origin.y, btn.size.width, 0); self.layer.shadowOffset = CGSizeMake(-5, -5); }else if ([direction isEqualToString:@"down"]) { self.frame = CGRectMake(btn.origin.x, btn.origin.y+btn.size.height, btn.size.width, 0); self.layer.shadowOffset = CGSizeMake(-5, 5); } self.layer.masksToBounds = NO; self.layer.cornerRadius = 8; self.layer.shadowRadius = 5; self.layer.shadowOpacity = 0.5; table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, btn.size.width, 0)]; table.delegate = self; table.dataSource = self; table.layer.cornerRadius = 5; table.backgroundColor = [UIColor colorWithRed:0.239 green:0.239 blue:0.239 alpha:1]; table.separatorStyle = UITableViewCellSeparatorStyleSingleLine; table.separatorColor = [UIColor grayColor]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.5]; if ([direction isEqualToString:@"up"]) { self.frame = CGRectMake(btn.origin.x, btn.origin.y-*height, btn.size.width, *height); } else if([direction isEqualToString:@"down"]) { self.frame = CGRectMake(btn.origin.x, btn.origin.y+btn.size.height, btn.size.width, *height); } table.frame = CGRectMake(0, 0, btn.size.width, *height); [UIView commitAnimations]; [b.superview addSubview:self]; [self addSubview:table]; } return self; } </code></pre> <p>Error:</p> <pre><code> Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Requesting the window of a view (&lt;NIDropDown: 0x684ac50; frame = (0 0; 0 0); transform = [0, 0, 0, 0, 0, 0]; alpha = 0; opaque = NO; layer = (null)&gt;) with a nil layer. This view probably hasn't received initWithFrame: or initWithCoder:. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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