我有一个问题是在视图之间有间隙,只在iphone 6和iphone 6plus的scrolliew中组合。它适用于iPhone 5。 我通过cgrect给图像,文本,按钮框架,这在所有手机的屏幕上看起来很好但是遇到了这个设计问题。所有数据都是从WebService获取的,采用JSON格式,然后进行解析。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0)
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"second"];
UIView *contentData = [cell viewWithTag:3];
NSLog(@"content data height is %f",contentData.frame.size.height);
// contentData.backgroundColor = [UIColor grayColor];
UIScrollView *scrollV =(UIScrollView *)[cell viewWithTag:100];
int i = 0;
for (i = 0;i<self.categor.bestsellerlist.count;i++)
{
UIView *bestsellerview = [[UIView alloc]init];
bestsellerview.backgroundColor = [UIColor whiteColor];
// UITapGestureRecognizer * tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapFrom :)]; [bestsellerview addGestureRecognizer:tapGestureRecognizer]; bestsellerview.tag = i;
bestsellerview.frame = CGRectMake(i*(((320-30)/2)+5),0,((320-30)/2),(((320-30)/2))*1.79);
AsyncImageView *asy = [[AsyncImageView alloc]init];
asy.frame = CGRectMake((bestsellerview.frame.size.width/2)-((((320-30)/2)*0.75)/2),10,(((320-30)/2)*0.75),(((320-30)/2)*0.85));
asy.backgroundColor = [UIColor clearColor];
NSLog(@"Bestseller view%@",NSStringFromCGRect(bestsellerview.frame));
NSLog(@"AsyncImage view%@",NSStringFromCGRect(asy.frame));
NSURL *url = [NSURL URLWithString: [[NSString stringWithFormat:@"%@%@",imageUrl,[[self.categor.bestsellerlist objectAtIndex:i]valueForKey:@"imagefilestd"]] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSLog(@"url is %@",url);
[asy loadImageFromURL:url];
[bestsellerview addSubview:asy];
// displayname
UILabel *name = [[UILabel alloc]init];
NSLog(@"yname is %f",asy.frame.origin.y+asy.frame.size.height+10);
name.text =[[self.categor.bestsellerlist objectAtIndex:i]valueForKey:@"prodname"];
name.frame = CGRectMake(0,138,bestsellerview.frame.size.width-5,44);
[name setFont:[UIFont systemFontOfSize:12]];
name.textAlignment = NSTextAlignmentCenter;
name.numberOfLines = 3;
name.lineBreakMode = NSLineBreakByWordWrapping;
name.textColor = [UIColor blackColor];
[UtitlityClass setLableLayout:name];
[bestsellerview addSubview:name];