Note that there are some explanatory texts on larger screens.

plurals
  1. POUIScrollView set its contentOffset default?
    primarykey
    data
    text
    <p>I have a scroll view which consists of many of views. These views are placed in the view according to their dynamic size. There is also a delete button on each view which deletes the view from the scrollview, and replace the others accordingly.</p> <p>But I have a problem, when I delete something scrollview does not stay where I deleted. One row up or down.</p> <p>This is my deletion code:</p> <pre><code>-(void) redrawTheList:(id)sender :(NSString*) except{ int tempo = counterRow; NSMutableDictionary *doctorTemp = [[NSMutableDictionary alloc]initWithDictionary:doctorAddition copyItems:YES]; for(int i = 0; i&lt;=tempo;i++) { NSString *dictTempKey = [NSString stringWithFormat:@"row%d",i]; NSMutableArray * tempArray = [doctorTemp objectForKey:dictTempKey]; for(UIView * subview in tempArray) { for(UIView * subview2 in [subview subviews]) { if([subview2 isKindOfClass:[UILabel class]]) { if([((UILabel*)subview2).text isEqualToString:except]) { counterRow = i; tempile = i; yAxis=5.0+(i*40.0); } } } } } for(int j=tempile;j&lt;=tempo;j++) { NSString *dictTempKey2 = [NSString stringWithFormat:@"row%d",j]; NSMutableArray * tempArray = [doctorAddition objectForKey:dictTempKey2]; for(UIView * subview in tempArray) { [subview removeFromSuperview]; } [doctorAddition removeObjectForKey:dictTempKey2]; } for(int k=tempile;k&lt;=tempo;k++) { NSString *dictTempKey3 = [NSString stringWithFormat:@"row%d",k]; NSMutableArray * tempArray2 = [doctorTemp objectForKey:dictTempKey3]; for(UIView * subview in tempArray2) { for(UIView * subview2 in [subview subviews]) { if([subview2 isKindOfClass:[UILabel class]]) { if(![((UILabel*)subview2).text isEqualToString:except]) { [self createDoctorBox:((UILabel*)subview2).text]; } } } } } } </code></pre> <p>CreateDoctorBox method;</p> <pre><code>-(UIView*)createDoctorBox : (NSString*)name { [addedList addObject:name]; NSString *myString = name; CGSize stringSize = [myString sizeWithFont:[UIFont fontWithName:@"Helvetica-Bold" size:13]]; UIView *doktorKutu = [[UIView alloc]init]; [doctorList addSubview:doktorKutu]; UIView *doktorKutuBas = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 18, 36)]; [doktorKutuBas setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"doktor_isim_kutu_bas"]]]; [doktorKutu addSubview:doktorKutuBas]; UILabel * doktorKutuGovde = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, stringSize.width+3, 36)]; [doktorKutuGovde setFont:[UIFont fontWithName:@"Helvetica-Bold" size:12]]; [doktorKutuGovde setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"doktor_isim_kutu_1px"]]]; [doktorKutuGovde setUserInteractionEnabled:YES]; [doktorKutuGovde setText:myString]; [doktorKutu addSubview:doktorKutuGovde]; UIView * doktorKutuKic = [[UIView alloc]initWithFrame:CGRectMake(stringSize.width+13, 0, 18, 36)]; [doktorKutuKic setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"doktor_isim_kutu_kic"]]]; [doktorKutu addSubview:doktorKutuKic]; UIImageView *cancelImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"cikar"]]; cancelImage.frame = CGRectMake(-5,9, 18, 18); [doktorKutuKic addSubview:cancelImage]; UIButton *cancel = [[UIButton alloc]initWithFrame:CGRectMake(-5,0, 20, 36)]; [cancel setUserInteractionEnabled:YES]; [cancel addTarget:self action:@selector(removeNameFromTheList:) forControlEvents:UIControlEventTouchUpInside]; [doktorKutuKic addSubview:cancel]; UITapGestureRecognizer *singlePress =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSinglePress:)]; [doktorKutuGovde addGestureRecognizer:singlePress]; [doktorKutu bringSubviewToFront:cancel]; [doctorCommented addObject:doktorKutu]; [doktorKutuKic bringSubviewToFront:cancel]; [doktorKutu bringSubviewToFront:cancel]; dictRowKey = [NSString stringWithFormat:@"row%d",counterRow]; NSMutableArray *row = [[NSMutableArray alloc]init]; doktorKutu.frame = CGRectMake(5, yAxis, stringSize.width+30, 36); if([doctorAddition objectForKey:dictRowKey]!=nil) { row = (NSMutableArray*)[doctorAddition objectForKey:dictRowKey]; if(row.count&gt;0) { int totalWidth = 5; for(int i=0;i&lt;row.count;i++) { totalWidth = totalWidth + ((UIView*)[row objectAtIndex:i]).frame.size.width+5; } if(totalWidth+stringSize.width&lt;520) { doktorKutu.frame = CGRectMake(totalWidth, yAxis, stringSize.width+30, 36); [row addObject:doktorKutu]; [doctorAddition removeObjectForKey:dictRowKey]; [doctorAddition setObject:row forKey:dictRowKey]; } else { doktorKutu.frame = CGRectMake(5, yAxis+40, stringSize.width+30, 36); yAxis= yAxis + 40.0; counterRow++; dictRowKey = [NSString stringWithFormat:@"row%d",counterRow]; row = [[NSMutableArray alloc]init]; [row addObject:doktorKutu]; [doctorAddition setObject:row forKey:dictRowKey]; } } } else { [row addObject:doktorKutu]; [doctorAddition setObject:row forKey:dictRowKey]; } [doctorList setContentSize:CGSizeMake(10, 36+(counterRow*41))]; return doktorKutu; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
    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